Commit Graph

179 Commits

Author SHA1 Message Date
Sebastian Geisler 79a88e1612 Move fuzzing code out of utils 2018-12-03 16:31:13 -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
Roman Zeyde 69ea2a760b
Fix 2 small typos in comments 2018-06-09 22:27:40 +03:00
Andrew Poelstra 62d080afc7
Merge pull request #83 from tamasblummer/is_coinbase
add is_coin_base
2018-06-04 18:46:03 +00:00
Tamas Blummer 3921899c65 add is_coin_base
add data access as copy
2018-06-01 21:39:51 +02:00
Igor Aleksanov 34e228c699 Added regtest
Completed regtest integration to the code

Added tests for regtest

Get rid of panics
2018-05-29 12:21:41 +03:00
Roman Zeyde 44d0ad90e9
block: fix a small typo in comment 2018-04-11 12:23:15 +03:00
Matt Corallo 8aa6253a3b Correct consensus verify args, fix tests to catch error in travis 2018-04-02 15:38:43 -04:00
Matt Corallo bfe889904a Fix whitespace (s/\t/ /g) 2018-04-02 14:58:25 -04:00
Matt Corallo 3793b2859a Add a Transaction.get_weight() method, check it in fuzzing 2018-04-02 12:23:05 -04:00
Matt Corallo a33f00621b Move witness inside of TxIn.
This is a rather large breaking API change, but is significantly
more sensible. In the "do not allow internal representation to
represent an invalid state" category, this ensures that witness
cannot have an length other than the number of inputs. Further,
it reduces vec propagation, which may help performance in some
cases by reducing allocs. Fianlly, this just makes more sense (tm).
Witness are a per-input field like the scriptSig, placing them
outside of the TxIn is just where they are serialized, not where
they logically belong.
2018-03-26 10:25:33 -04:00
Matt Corallo 6826d8f35c Stub out Sha2 calls when fuzzing to mask all but the first byte 2018-03-21 18:44:10 -04:00
Tamas Blummer 1a87244b2b Implement Segwit addresses 2018-03-20 18:26:51 +01:00
Tamas Blummer 755fb454eb integration with bitcoinconsenus 2018-03-12 17:17:16 +01:00
Andrew Poelstra 21f2baf58e remove script interpreter 2018-03-09 20:30:11 +00:00
Tamas Blummer 77ce6f18d0 Moved blockchain and patricia_tree to rust-memblocks 2018-03-09 17:22:31 +01:00
Andrew Poelstra 7dcca9157b
Merge branch 'master' into is_on_main_chain_public2 2018-03-09 15:09:21 +00:00
Tamas Blummer 5e510366cf is_on_main_chain is a very useful function upstream, make it public 2018-03-03 18:15:05 +01:00