Commit Graph

238 Commits

Author SHA1 Message Date
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 0e1d927b47 Only provide the required TxIn to bip143 sighash_all.
This resolves an very unergonomic API by allowing iteration over a
Transaction being signed's inputs without needing to take a
conflicting reference to the transaction.

The API is still relateively unsafe in that its very easy to
generate bogus sighashes with it, but this is much better than it
was, and its not clear how to fix it further.
2018-04-02 12:42:59 -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 f859dc8b26 Expose VarInt's encoded length 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
Tamas Blummer ae708447a2 create Address message with SocketAddr, get SocketAddr from Address message. 2018-03-23 15:12:06 +01:00
Matt Corallo 855b377d51 Fix crash in Address::from_str if input isn't long enough 2018-03-21 18:44:10 -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
Andrew Poelstra 64987e349c minor nits to get compilation to work on rustc 1.14 (currently shipping Debian version) 2018-03-21 18:49:46 +00:00
Tamas Blummer 1a87244b2b Implement Segwit addresses 2018-03-20 18:26:51 +01:00
Andrew Poelstra 65d8df08b8 address: implement Bech32 support 2018-03-13 14:48:01 +00:00
Andrew Poelstra 9884bec577 add docs indicating change in Sha256dHash debug output 2018-03-12 21:50:35 +00:00
Andrew Poelstra 8968b081ca util: add Debug output for Sha256d and Hash160 which don't reverse the bytes 2018-03-12 21:27:09 +00:00
Andrew Poelstra ee1dfcf4a2 base58: remove Base58 traits, replace with encode/decode functions 2018-03-12 21:27:07 +00: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
Tamás Blummer e530aa98c9
Merge branch 'master' into is_on_main_chain_public2 2018-03-09 16:03:06 +01:00
Andrew Poelstra ab72eabd59
Merge branch 'master' into get_tip_height 2018-03-09 15:01:15 +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
Tamas Blummer 3351f35583 add documentation 2018-02-28 20:27:52 +01:00
Tamas Blummer 50a9d0f51f add get_best_tip_height to blokchain 2018-02-28 20:24:35 +01:00
Tamas Blummer f1503866d7 RawNetworkMessage::command should be public. no harm and useful for debug messages. 2018-02-28 10:42:23 +01:00
Andrew Poelstra 066c49305f update secp256k1 to latest version with minimized dependencies 2018-02-20 16:19:29 +00:00
Andrew Poelstra 23a2c6bc9a remove `jsonrpc` dependency by copying the macro we need into the source 2018-02-18 15:28:39 +00:00
Andrew Poelstra 047c0c149d remove `num` crate dependency 2018-02-18 15:21:13 +00:00
Andrew Poelstra 9562d8afac
Merge pull request #41 from tamasblummer/minimal_alert_message
minimal implementation of alert message
2018-02-18 15:00:55 +00:00
Andrew Poelstra 71bce7b067
Merge pull request #44 from tamasblummer/add_difficulty2
Add difficulty calculation
2018-02-18 14:59:36 +00:00
Andrew Poelstra 91a786d22c
Merge pull request #42 from tamasblummer/add_low_u64
add low_u64 to Uint256 and Uit128 types
2018-02-18 14:57:37 +00:00
Andrew Poelstra 3547d27430
Merge pull request #40 from tamasblummer/unit_debug_fix
fixing debug output for Uint256 and Uint128
2018-02-18 14:57:00 +00:00
Andrew Poelstra 7930d14124
Merge pull request #38 from apoelstra/bip143
util: add `bip143` module to create BIP143 signature hashes
2018-02-16 22:13:55 +00:00
Andrew Poelstra 9f092a6f31 remove all use of mem::uninitialized and mem::copy_nonoverlapping 2018-02-14 16:53:49 +00:00
Matt Corallo 9052f3b5a2 Fix argument to copy_nonoverlapping in internal_macros
This resolves a segfault due to unsafe code.
2018-02-13 19:08:10 -05:00
Tamas Blummer 3efe511cc6 add difficulty calculation 2018-02-11 19:58:26 +01:00
Tamas Blummer 19f96fe62c add low_u64 to Uint256 and Uit128 types 2018-02-11 14:19:58 +01:00
Tamas Blummer 9fbe941621 minimal implementation of alert message 2018-02-11 14:08:33 +01:00
Tamas Blummer e05f45beb0 fixing debug output for Uint256 and Uint128 2018-02-11 14:04:35 +01:00
Andrew Poelstra f233fcac61 util: add `bip143` module to create BIP143 signature hashes 2018-01-15 17:54:32 +00:00
Andrew Poelstra b3644b7b6d add constants for OP_CLTV and OP_CSV 2017-12-21 01:10:00 +00:00
Andrew Poelstra 406160a386 transaction: add txid() function that does the right thing for segwit/nonsegwit
With Segwit transactions `bitcoin_hash()` is no longer sufficient to get a txid.
2017-12-09 19:52:09 +00:00
Andrew Poelstra c691d0e382 util: add Sha256dEncoder to allow streaming data into a hash
This is needed to for a sane BIP143 implementation. Should be exactly equivalent to
serializing data into a vector then hashing that vector for all types.
2017-12-06 16:50:47 +00:00
Andrew Poelstra e5f109221e script: add `to_p2wsh()` and `is_p2swsh()` functions to allow easy segwit output computation 2017-12-06 15:39:37 +00:00
Andrew Poelstra c341e21dc6
remove unnecessary `mut` that nightly rustc has learned to detect 2017-10-06 19:56:50 +00:00
Andrew Poelstra 46439710d9
script: add `is_p2pkh()` function 2017-10-06 19:15:30 +00:00
Andrew Poelstra 8f7bd858fb
update byteorder to 1.1 from 0.3 2017-07-28 16:19:44 +00:00
Andrew Poelstra 2e7be81ea4 add unit test for overflow panic 2017-06-07 16:09:40 +00:00
Daniel Lockyer a74efe6f8c Sanity checks for vector length 2017-06-05 18:06:30 +01:00
Andrew Poelstra cdb452f79f Sanity-check vector length when deserializing 2017-04-17 00:54:38 +00:00