Commit Graph

251 Commits

Author SHA1 Message Date
Steven Roose 385a657974
Refactor Address
- use AddressError instead of encode::Error
- replace using bech32-bitcoin with Payload::WitnessProgram variant
2019-08-13 08:47:10 +01:00
Andrew Poelstra cc0f1143dc
Merge pull request #309 from elichai/2019-08-amount-precision
Check that the amount precision isn't more than the size of the amount
2019-08-12 17:20:18 +00:00
Riccardo Casatta 7d6687451a use BTreeMap instead of HashMap to always serialize the same (#310)
* use BTreeMap instead of HashMap to always serialize the same

* fix rust 1.22 error

* psbt fuzz roundtrip

* psbt fuzz roundtrip on our ser
2019-08-09 17:03:12 +02:00
Tamás Blummer 4ddf6f80b9
Reduce blockfilter memory (#302)
* use same Error type in all methods of BlockFilter

* reduce Blockfilter memory footprint

* amend the example use

* remove unused constant
2019-08-09 16:58:02 +02:00
Elichai Turkel a9e65f36d3
Check that the amount precision isn't more than the size of the amount 2019-08-09 10:41:21 -04:00
practicalswift 8152ed758c Fix typos 2019-08-04 19:27:36 +00:00
Steven Roose 2c2d55d90a
bip32: Implement hex serialization for Fingerprint and ChainCode 2019-07-26 15:32:33 +02:00
Steven Roose 3c66418f3a
bip32: Add serde for Extended(Priv|Pub)Key 2019-07-26 15:30:44 +02:00
Tamás Blummer c93a70487f
Add client side block filter (BIP158) (#281)
* add client side block filters with code from murmel. use siphash from bitcoin_hashes pass Bitcoin Core tests upgrade to bitcoin_hashes 0.7

* add filter.filter_id() test use BlockFilter directly

* fixed edge cases of matching empty query sets or or using empty filter
2019-07-26 09:36:25 +02:00
Andrew Poelstra b6c1266102
Merge pull request #293 from stevenroose/bip143-script-code
bip143: Rename witness_script to script_code
2019-07-24 22:43:58 +00:00
Steven Roose b312c4de6a
bip143: Rename witness_script to script_code
For p2wsh the scriptCode is the witness script, but for p2wpkh, it's the
equivalent legacy p2pkh output script.
The name scriptCode is used in the BIP, so it's less confusing.
2019-07-15 17:33:23 +02:00
Andrew Poelstra 3b9a94a178 eliminate type parameter from the `Decodable` trait 2019-07-11 17:23:01 +00:00
Andrew Poelstra 42960b959f eliminate type parameter from `Encodable` trait 2019-07-11 17:21:19 +00:00
Andrew Poelstra b734d6488a make consensus_encode return the encoded length 2019-07-11 17:15:32 +00:00
Andrew Poelstra 7e6ad7c893 rename Encoder to WriteExt and Decoder to ReadExt 2019-07-11 15:01:38 +00:00
Andrew Poelstra 24ebc29005 fix some recent rustc warnings 2019-07-11 15:01:38 +00:00
John L. Jegutanis aae2937d11 Add a MerkleBlock construction
This is a port of the bitcoin-core CPartialMerkleTree and CMerkleBlock classes.
Here they are called PartialMerkleTree and MerkleBlock.

These are useful for SPV clients that wish to verify that a transaction is
present in a specific block in an authenticated way.
2019-07-05 20:44:31 +02:00
Andrew Poelstra cded694381
Merge pull request #277 from jonasnick/rand
Remove unused rand dependency
2019-07-03 20:42:44 +00:00
Andrew Poelstra b2727b6ebe
Merge pull request #250 from stevenroose/no-strason
Remove Decimal and replace strason with serde_json
2019-07-03 17:30:21 +00:00
Steven Roose 30201f3924
Remove Decimal and replace strason with serde_json 2019-06-13 18:29:16 +01:00
Jonas Nick 94fba3aa88 Remove unused rand dependency 2019-06-10 13:59:31 +00:00
Jonas Nick 30f24a39d0 Remove confusing mentions of SPV 2019-06-07 13:12:07 +00:00
Andrew Poelstra a6c1eacd70
Merge pull request #270 from stevenroose/signed-amount
Add Amount and SignedAmount
2019-06-07 09:16:02 +00:00
Steven Roose 688d95b463
Add Amount and SignedAmount types 2019-05-31 10:18:59 +01:00
Steven Roose d4282353c9
Two serde quirks from switching dependencies 2019-05-31 10:18:57 +01:00
Matt Corallo 7015b064dd Add slice consensus encode/decode functions and use for short arrays 2019-05-30 11:25:37 -04:00
Andrew Poelstra 4139f2a1ca
Merge pull request #258 from shesek/signed-msg-hash
Implement util::misc::signed_msg_hash()
2019-05-30 14:35:57 +00:00
Steven Roose bb8520268e
bip32: Add DerivationPathIterator and related methods
Adds methods
- ChildNumber::increment
- DerivationPath::children_from
- DerivationPath::normal_children
- DerivationPath::hardened_children
2019-05-03 17:58:09 +01:00
Nadav Ivgi 473b491409
Implement util::misc::signed_msg_hash() 2019-04-28 09:01:42 +03:00
Andrew Poelstra dc6189dbb2 contracthash: more cleanups 2019-03-21 21:27:26 +00:00
Andrew Poelstra 01a3a9263c contracthash: use `PublicKey` and `PrivateKey` types; minor cleanups 2019-03-21 21:27:26 +00:00
Andrew Poelstra 3700d100eb contracthash: add fixed test vector 2019-03-21 21:27:26 +00:00
Andrew Poelstra 9daf7fa9dc util::key add serde de/serialization 2019-03-21 18:27:42 +00:00
Steven Roose 459059622f
util:🔑 Provide to_bytes() methods for key types
These are mainly utility methods around the existing way to serialize
the key types.
2019-03-05 16:07:52 +00:00
Andrew Poelstra 4dbf431ecd key: implement ToString and FromStr for PublicKey 2019-03-04 01:06:19 +00:00
Carl Dong e5b59120c5 Add copyright notice to PSBT-related files 2019-02-28 11:11:55 -05:00
Carl Dong bc73b315cb Add test vectors from BIP174 specification
- Add macro for decoding and unwrapping PartiallySignedTransaction from
  hex string
2019-02-28 11:11:55 -05:00
Carl Dong 39fd567b56 Add Partially Signed Transaction type
- Add merging logic for PartiallySignedTransactions
- Add (en)decoding logic for PartiallySignedTransaction
- Add converting constructor logic from Transaction for
  PartiallySignedTransaction
- Add extracting constructor logic from PartiallySignedTransaction for
  Transaction

Squashed in fixes from stevenroose <stevenroose@gmail.com>

- Prevent PSBT::extract_tx from panicking
- Make PartiallySignedTransaction fields public
2019-02-28 11:11:55 -05:00
Carl Dong badb0f2a77 Add PSBT input data key-value map type
- Implement psbt::Map trait for psbt::Input
- Add (en)decoding logic for psbt::Input

- Implement PSBT (de)serialization trait for relevant psbt::Input types
2019-02-28 11:11:55 -05:00
Carl Dong 9c08dbae47 Add PSBT output data key-value map type
- Implement psbt::Map trait for psbt::Output
- Add (en)decoding logic for psbt::Output

- Implement PSBT (de)serialization trait for relevant psbt::Output types

- Add macro for merging fields for PSBT key-value maps
- Add macro for implementing decoding logic for PSBT key-value maps
- Add convenience macro for implementing both encoding and decoding
  logic for PSBT key-value maps
- Add macro for inserting raw PSBT key-value pairs into PSBT key-value
  maps
- Add macro for getting raw PSBT key-value pairs from PSBT key-value
  maps
2019-02-28 10:54:53 -05:00
Carl Dong 115f8c043c Add PSBT global data key-value map type
- Implement psbt::Map trait for psbt::Global
- Add converting constructor logic from Transaction for psbt::Global
- Add (en)decoding logic for psbt::Global
  - Always deserialize unsigned_tx as non-witness

- Add trait for PSBT (de)serialization
- Implement PSBT (de)serialization trait for relevant psbt::Global types

- Add macros for consensus::encode-backed PSBT (de)serialization
  implementations
- Add macro for implementing encoding logic for PSBT key-value maps
2019-02-28 10:54:53 -05:00
Carl Dong 2715a6e777 Add trait for PSBT key-value maps 2019-02-28 10:54:53 -05:00
Carl Dong 528e39334c Add data types for raw PSBT key-value pairs
- Add (en)decoding logic for said data types
2019-02-28 10:54:53 -05:00
Carl Dong 4fa39c4a3e Add PSBT-specific Error data type
- Implement psbt::Error data type
- Implement conversion from psbt::Error to util::Error
- Create util::psbt module
- Create non-public util::psbt::error module
2019-02-28 10:54:53 -05:00
Andrew Poelstra 4f74ae61c4 bip32: replace rust-secp key types with rust-bitcoin key types
We continue to support only compressed keys when doing key derivation,
but de/serialization of uncompressed keys will now work, and it will
be easier/more consistent to implement PSBT on top of this.
2019-02-27 22:21:40 +00:00
Andrew Poelstra fc47c477ab key: add some missing functionality 2019-02-27 01:56:38 +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 d5331e59ed
Merge pull request #233 from stevenroose/derivation-path
bip32: Add DerivationPath type
2019-02-15 09:52:59 -05:00
Steven Roose dce81b623e
bip32: Add additional methods and traits to DerivationPath
- From<&[ChildNumber]> (cloning)
- AsRef<[ChildNumber]>
- std::iter::FromIterator<ChildNumber>
- std::iter::IntoIterator<ChildNumber>
- std::ops::Index (returning &[ChildNumber])

Also add two methods:
- child(&self, ChildNumber) -> DerivationPath
- into_child(self, ChildNumber) -> DerivationPath
2019-02-14 11:16:06 +00:00
Steven Roose 1373969805 bip32: Change test vectors to use DerivationPath 2019-02-14 11:09:39 +00:00