Commit Graph

195 Commits

Author SHA1 Message Date
Andrew Poelstra 049f75e502 script: add `push_key` function to Builder to allow serializing public keys more easily 2019-03-04 01:32:35 +00:00
Matt Corallo 084703cba9
Merge pull request #218 from tamasblummer/merkle_root_fix
Merkle root calculation and witness commitment check for Block
2019-02-16 19:05:42 -05:00
Carl Dong 560dfb7c01
Merge pull request #203 from stevenroose/asm
Extract the Script assembly creator from fmt::Debug
2019-02-11 17:24:03 -05:00
ariard 51971dd533 Fix typos and clarify some comment in blockdata, block, address (#230) 2019-02-04 07:30:41 +01:00
Tamas Blummer d8c93d9935 Implement Witness commitment check for Block. Remove MerkleRoot implementations for types implementing BitcoinHash as
it is misleading. MerkleRoot is defined instead for a Block.
2019-02-01 17:46:26 +01:00
Carl Dong 99f63a8ca4 Convert codebase from util::hash to bitcoin_hashes
Also replace unsafe transmute with call to read_u64_into
2019-01-24 16:27:52 -05:00
Dimitris Apostolou 132ca5ea95 Fix typos 2019-01-23 14:17:29 -05:00
Antoine Riard 96c66292c8 Fix comment on transaction version 2019-01-10 18:29:50 -08:00
Steven Roose a10d5e15b3
Extract the Script assembly creator from fmt::Debug 2018-12-19 21:17:00 +01:00
Andrew Poelstra 5a5158e120
Merge pull request #198 from sgeisler/safe-opcodes
Safe opcodes 1.14.0
2018-12-14 16:32:29 +00:00
Sebastian Geisler a6d204cbda Fix indentation in opcodes.rs 2018-12-13 15:35:29 -08:00
Andrew Poelstra 617406228a add some opcode tests 2018-12-09 16:30:23 +00:00
Sebastian Geisler 9fee72cf20 make opcode PR work with 1.14.0 2018-12-04 15:56:18 -08:00
Sebastian Geisler 79a88e1612 Move fuzzing code out of utils 2018-12-03 16:31:13 -08:00
Kaz Wesley 6b67c8cdff squashme: work around lack of associated constants 2018-11-11 14:58:33 -08:00
Kaz Wesley 45234eb09a safe implementation of All -> Ordinary 2018-11-11 14:19:25 -08:00
Kaz Wesley 0bfef68851 newtype implementation of opcodes::All
Removes unsafety when converting u8 -> All
2018-11-11 14:11:06 -08:00
Nadav Ivgi 18fcab6715 Detect compressed p2pk in script.is_p2pk() 2018-11-08 02:37:27 +02:00
Andrew Poelstra b8a72448df
Merge pull request #153 from rust-bitcoin/2018-08-segwit-ambiguity
transaction: make 0-input de/serialization always use Segwit
2018-11-03 15:29:51 +00:00
Steven Roose fefd5d4fe2 Implement FromStr for OutPoint 2018-10-18 12:37:02 +01:00
Andrew Poelstra 11a2783235 add comment expanding on the segwit ambiguity 2018-10-10 02:45:09 +00:00
Andrew Poelstra a181a523c6 remove special case for 0-input 0-output transaction deserialization
This creates two ways to encode an empty transaction; we should use only the
Segwit-enabled one because that's what we do for 0-input non-0-output transactions.
2018-10-10 02:03:08 +00:00
Andrew Poelstra 98e39b4383 transaction: make 0-input de/serialization always use Segwit 2018-09-27 13:50:35 +00:00
Carl Dong 0f42ca69b0 Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
  consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
  instead
- Move network::serialize::Simple{En,De}coder to
  consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
  should never fail
2018-09-25 21:19:35 +08:00
Carl Dong 8e0e4eb55a Move serialize::BitcoinHash to util:#️⃣:BitcoinHash
- Use Sha256dEncoder for calculating merkle root
- Remove BitcoinHash implementation for Vec<u8>
2018-09-25 21:19:10 +08:00
Andrew Poelstra fe99a88acf
Merge pull request #152 from rust-bitcoin/2018-08-script-ord
impl PartialOrd, Ord for Script
2018-08-26 15:38:43 +00:00
Andrew Poelstra b33aa6fa6c add unit test for script ordering 2018-08-25 22:09:22 +00:00
Andrew Poelstra f0221fb79b transaction: reject transactions with Segwit byte set but no witnesses 2018-08-24 19:57:58 +00:00
Andrew Poelstra 68413d306d impl PartialOrd, Ord for Script 2018-08-24 02:20:37 +00:00
Andrew Poelstra 08db6fe29f script: let Instructions iterator enforce minimal pushes; remove `IntoIter` impl to force users to choose 2018-08-22 19:55:31 +00:00
Carl Dong 0c172941af Replace serialize::Error::Detail with variants
- Add serialize::Error::ParseFailed(&'static str) variant for
  serialization errors without context
- Add appropriate variants to replace network::Error::Detail for
  serialization error with context
- Remove error method from SimpleDecoders
2018-08-21 01:58:40 -07:00
Carl Dong 95303a1d28 Use full path in macros to to eliminate uses 2018-08-21 01:58:40 -07:00
Carl Dong e5b5cbfadb Fix Error type for SimpleDecoder and SimpleEncoder
- Separate serialize::Error and network::Error from util::Error
- Remove unneeded propagate_err and consume_err
- Change fuzzing code to ignore Err type
2018-08-21 01:58:40 -07:00
Jean Pierre Dudey 4dfb98bd70 Use `as_`,`to_`,`into_` conventions for array types.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 17:20:43 -04:00
Andrew Poelstra 2d961412af
Merge pull request #139 from jeandudey/2018-08-18-outpoint
Rename `TxOutRef` to `OutPoint` and use it in `TxIn`.
2018-08-20 18:18:00 +00:00
Jean Pierre Dudey 32631e44ad Rename `TxOutRef` to `OutPoint` and use it in `TxIn`.
Previously this structure was unused, it's now being used by the `TxIn`
structure to simplify the code a little bit and avoid confusions. Also
the rust-lightning source code has an `OutPoint` similar to this one
but with the `vout` index as an `u16` to avoid unsafe conversions.

I've added to new methods to `OutPoint`:

- `null`: Creates a new "null" `OutPoint`.
- `is_null`: Checks if the given `OutPoint` is null.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 13:46:10 -04:00
Jean Pierre Dudey 1b4aba1d80 Update serde to 1.0 and strason to 0.4
The `serde_struct_impl!` macro has been modified to be compatible
with the serde 1.0 crate, we use this macro and not the `serde_derive`
crate because the latter doesn't support Rust 1.14.0 which is shipped
on Debian stable and we should remain compatible with it.

Two new features were added:

- "serde": enables serialization/deserialization for common types, it pulls
the serde 1.0 dependency.
- "serde-decimal": enables serialization/deserialization for `UDecimal`/`Decimal`,
this pulls the strason 0.4 depdendency and the serde 1.0 dependency.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 13:42:34 -04:00
Carl Dong 9da96e1d46 Fix compilation warning when comparing usize and u64 on 32-bit arch 2018-08-17 10:08:56 -07:00
Andrew Poelstra 6c82001ead
Merge pull request #128 from jeandudey/2018-08-12-bitcoinconsenus
Remove unused "bitcoinconsenus" feature.
2018-08-15 20:55:51 +00:00
Andrew Poelstra bc7125e955
Merge pull request #119 from jeandudey/2018-08-08-try-op
Remove `try!` macro usage and use the `?` operator instead.
2018-08-12 23:44:43 +00:00
Jean Pierre Dudey f918311b8a Remove unused "bitcoinconsenus" feature.
Also I've updated the feature name on the README.md, and fixed a typo in
src/blockdata/script.rs

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 16:06:06 -04:00
Jean Pierre Dudey 6e99d2d33c Hidde `From<T>` implementations for error types in Rustdoc.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:57:59 -04:00
Jean Pierre Dudey b2594087db Use the `?` (try) instead of the `try!` macro.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:47:31 -04:00
Jean Pierre Dudey 77c185d9ec Fix modules documentation title.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-08 17:38:50 -04:00
Andrew Poelstra 45c699f005
Merge pull request #112 from TheBlueMatt/2018-07-p2wsh-name
Clarify to_v0_p2wsh docs a bit further
2018-07-28 18:28:00 +00:00
Matt Corallo 3686cd7201 Clarify to_v0_p2wsh docs a bit further 2018-07-26 15:13:44 -04:00
Savil Srivastava 933dcaeb82 [code hygiene] remove deprecated rustc-serialize
Addresses #96.

Turns out it was being used for hex encoding/decoding, so replaced that with the `hex` crate.

i chose to import the `decode` method as:
```
use hex::decode as hex_decode
```

so that it is clear to the reader what is being decoded when it is called. "decode" is such a generic sounding function name that it would get confusing otherwise.
2018-07-26 09:49:15 -07:00
Carl Dong db76a63669
Fix to_v0_p2wsh docs 2018-07-25 17:11:27 -07:00
Tamas Blummer caeadb42be check if output is OP_RETURN 2018-06-23 14:49:55 +02:00
Igor Aleksanov 14a920ab7d Added method to convert target from Uint256 to compact form (#86)
Renamed method for getting compact from u256

Removed unnecessary asserts from convert function
2018-06-12 20:58:25 +02:00