Commit Graph

639 Commits

Author SHA1 Message Date
Riccardo Casatta 104836a042
implements alternate formatting for address 2021-04-07 15:49:58 +02:00
Dr Maxim Orlovsky 7fe3c4a605
Non-API breaking derives for error types 2021-04-06 14:44:50 +02:00
Riccardo Casatta cac3f460a2
improve to_qr_string doc 2021-03-23 09:42:58 +01:00
Riccardo Casatta d18554e756
Address to string conversion optimized for qr codes 2021-03-22 13:58:59 +01:00
Riccardo Casatta b9d5200448
Access Display and Formatter with fmt:: like in other places 2021-03-22 13:42:32 +01:00
Andrew Poelstra 20f1543f79
Merge pull request #552 from JeremyRubin/fix-amount-serde
Fix Optional Amount Serialization
2021-03-15 15:48:20 +00:00
Steven Roose 7df0d14f1a
Merge pull request #577 from RCasatta/proprietary_key
Include proprietary key in deserialized PSBT
2021-03-15 12:16:30 +00:00
Steven Roose 6a0f68df85
Merge pull request #557 from LNP-BP/psbt/display_from_str
PSBT base64 (de)serialization with Display & FromStr
2021-03-13 19:39:58 +00:00
carolcapps d52b88b525 Fix increment of Uint256 with carry 2021-03-13 15:19:43 +00:00
Riccardo Casatta 7e25c133d8
Include proprietary keys in deserialized fields 2021-03-13 15:41:07 +01:00
Riccardo Casatta fcd7200efe
Proprietary key test failing rtt 2021-03-13 15:19:21 +01:00
Andrew Poelstra bee5e8a090
Merge pull request #567 from LNP-BP/bip32/child-number-display
Improving bip32 ChildNumber display implementation
2021-03-12 21:01:56 +00:00
Jeremy Rubin a0c7f530ba Localize breaking changes of fixing the Amount serialization to only the
broken Option<SerdeAmount> serializer.
2021-02-28 09:13:52 -08:00
Dr Maxim Orlovsky 7b7b73f6d2
Improving PSBT FromStr error type 2021-02-22 12:46:22 +01:00
Dr Maxim Orlovsky 79f2729b20
Improving PSBT error tests 2021-02-22 12:46:22 +01:00
Dr Maxim Orlovsky 94102fa597
PSBT Base64 serialization test cases 2021-02-22 12:46:22 +01:00
Dr Maxim Orlovsky 072e1d1b86
PSBT Display & FromStr using Base64 serialization 2021-02-22 12:46:22 +01:00
Andrew Poelstra 2414c5b0a9
Merge pull request #573 from darosior/standard_sighash
SigHashType: add a method to error on non-standard hashtypes
2021-02-21 15:34:58 +00:00
Andrew Poelstra 81c56dec60
Merge pull request #551 from LNP-BP/feat/key-error-derives
More derives for key::Error
2021-02-21 14:14:54 +00:00
Sebastian 3ecab20c17
Merge pull request #414 from stevenroose/amount-debug
Change Amount Debug impl to BTC with 8 decimals
2021-02-21 15:14:40 +01:00
Antoine Poinsot e36f3a38e4
transaction: deprecate SigHashType::from_u32 in favor of from_u32_consensus
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-02-19 11:36:44 +01:00
Dr Maxim Orlovsky 017cd71ca7
Improving bip32 ChildNumber display implementation 2021-02-11 23:06:24 +01:00
Nadav Ivgi a1e98a6796
Implement Ord for ParseLengthError 2021-01-22 00:27:28 +02:00
Nadav Ivgi 55657cbffb
Implement Error and Eq for ParseLengthError 2021-01-16 13:02:22 +02:00
Nadav Ivgi 0df86b4426
Switch to a single-variant error type, implement standard derives 2021-01-14 22:17:18 +02:00
Jeremy Rubin da21294ac5 Fix Optional Amount Serialization 2021-01-14 10:46:20 -08:00
Nadav Ivgi 4a7cf34eeb
Use efficient serialization for non-human-readable formats 2021-01-14 19:36:36 +02:00
Nadav Ivgi b70361370b
Make uint types (un)serializable 2021-01-14 19:36:35 +02:00
Nadav Ivgi 67ae602e2a
Implement Uint::from_be_slice()
Needed because Rust 1.29 does not easily allow converting from a slice
into an array.
2021-01-14 19:36:30 +02:00
Nadav Ivgi 3761b0d808 Implement Uint::to_be_bytes() 2021-01-14 19:28:02 +02:00
Dr Maxim Orlovsky 246713821d
More derives for key error 2021-01-14 16:03:53 +01:00
Steven Roose 61918dfe81
Change the signature of consensus_encode to return io::Error's
This is instead of encode::Errors because the encoders should
not be allowed to return errors that don't originate in the writer
they are writing into.

This is a part of the method definition that has been relied upon for a
while already.
2021-01-12 17:39:41 +00:00
Andrew Poelstra b48f374c2c
Merge pull request #542 from apoelstra/2021-01--keyread
PublicKey: add read_from method to be symmetric with write_into
2021-01-11 19:50:04 +00:00
Andrew Poelstra 92000bf51b PublicKey: add read_from method to be symmetric with write_into 2021-01-04 19:07:27 +00:00
Steven Roose 5fd92d1c09 psbt: Serialize maps with byte values using hex 2020-12-30 16:32:52 +01:00
Steven Roose a05f8feec6 serde_util: Rename the btreemap module to btreemap_as_seq
So that we can later distinguish other modules over maps.
2020-12-30 16:32:52 +01:00
Steven Roose a9c13272a0 psbt: Fix serde for maps with non-string keys and binary values 2020-12-30 16:32:52 +01:00
Steven Roose e5f3bca2b4 Add serde_utils module to fix JSON serialization 2020-12-30 16:32:52 +01:00
Steven Roose cdedb0a9d5 psbt::raw: Use hex::format_hex to format the raw key bytes 2020-12-30 16:32:52 +01:00
Steven Roose 94b7371424 Replace serde_struct_impl with derive-based impls 2020-12-30 16:32:52 +01:00
Steven Roose d527a2c2cf Remove the impl_array_newtype_show macro
Instead, implement Debug in impl_bytes_newtype.
2020-12-30 16:32:52 +01:00
Andrew Poelstra 1cc466fec6
Merge pull request #498 from LNP-BP/pending/derivation
Derivation path improvements, closes #473
2020-12-28 00:53:25 +00:00
Dr Maxim Orlovsky 7400bccb60
PSBT: proprietary keys type system according to BIP 174 2020-12-21 12:22:35 +01:00
Dr Maxim Orlovsky c3024c3ebb
PSBT: basic support for proprietary keys 2020-12-21 12:17:07 +01:00
Dr Maxim Orlovsky 44ffddab8c
Impl IntoDerivationPath for string types 2020-12-20 23:39:01 +01:00
Dr Maxim Orlovsky f9290438cd
DerivationPath improvements
Adding IntoDerivationPath trait
DerivationPath is_master function
DerivationPath constructor for empty path + Default impl
2020-12-20 23:39:01 +01:00
Dr Maxim Orlovsky 7f5c2795d6
PSBT global xpub merging algorithm reworked 2020-12-20 11:41:24 +01:00
Dr Maxim Orlovsky b84faa7f5e
PSBT: Improved global keys version and xpub handling 2020-12-16 16:46:28 +01:00
Dr Maxim Orlovsky 21c11e3315
BSPT: Improving global xpub merging algorithm 2020-12-16 16:39:46 +01:00
Dr Maxim Orlovsky 8b1666295c
Nits in new PSBT global types reviews 2020-12-15 16:04:02 +01:00
Dr Maxim Orlovsky 0235abfac2
Improving PSBT merge with dedicated 1.29 rustc borrow scope 2020-12-15 15:50:18 +01:00
Dr Maxim Orlovsky df8635c5fe
PSBT: Key pair serialization for new global keys
Conflicts:
	src/util/psbt/map/global.rs
2020-12-15 15:50:18 +01:00
Dr Maxim Orlovsky 2f838218a8
PSBT: merging new global keys
Plus necessary changes to BIP 32 implementations and error type
2020-12-15 15:47:37 +01:00
Dr Maxim Orlovsky af61d7e7bc
PSBT: adding global types (version, xpub) 2020-12-15 15:47:37 +01:00
Steven Roose 6df16b7ce2
Merge pull request #530 from LNP-BP/psbt/constants
PSBT types are now constants
2020-12-15 14:45:52 +00:00
Steven Roose 874ab8eca6
Make signed message prefix a public constant 2020-12-08 17:31:28 +00:00
Dr Maxim Orlovsky 881f4d75dd
PSBT: Making hash preimage constant names match BIP 174 2020-12-07 16:35:28 +01:00
Dr Maxim Orlovsky 214e10baef
PSBT types are now constants 2020-12-07 15:37:16 +01:00
Steven Roose b4c8e12f36
Merge pull request #259 from stevenroose/taproot
Tagged hashes for taproot
2020-12-07 11:34:37 +00:00
Steven Roose f0ee94f2b2
Merge pull request #513 from LNP-BP/psbt/standard-names
PSBT: making input and output field names match spec type names
2020-12-07 11:34:06 +00:00
Dr Maxim Orlovsky 27037e2c72
PSBT: Making RIPEMD160 hash match standard name 2020-12-05 15:46:30 +01:00
Dr Maxim Orlovsky 9b106ee161
PSBT: making BIP32 field name match spec type names 2020-12-05 15:45:20 +01:00
Steven Roose a56712befc
Create tagged taproot hashes 2020-11-30 20:13:11 +00:00
Steven Roose ee192eb61d
Merge pull request #470 from LNP-BP/feat/bip32-bin
BIP 32 binary encoding functions are extracted from base58
2020-11-23 21:33:54 +00:00
Elichai Turkel 7c05673b86
Merge pull request #487 from RCasatta/map_with_u128
use u128 in map_to_range
2020-11-15 15:42:00 +02:00
Dr Maxim Orlovsky fa4ecb4a6a
Making ExtendedPubKey decode aligned with ExtendedPrivKey variant 2020-11-10 09:30:33 +01:00
Dr Maxim Orlovsky a802ca88ef
Using base58::check_encode_slice_to_fmt for BIP32 encodings 2020-11-08 18:29:30 +01:00
Dr Maxim Orlovsky d802872310
Improvements to extended keys encoding logic end errors 2020-11-08 13:03:32 +01:00
Dr Maxim Orlovsky 259259eabf
BIP 32 binary encoding functions are extracted from base58 2020-11-08 13:03:32 +01:00
Dr Maxim Orlovsky b5f0e9e144
Fixing serde impl for PSBT inputs 2020-11-06 17:01:34 +01:00
Andrew Poelstra d3210b39fb
Merge pull request #507 from stevenroose/pubkey-write-result
Change PublicKey::write_into to return Result
2020-11-05 19:21:39 +00:00
Andrew Poelstra 35d729d9f0
Merge pull request #478 from sanket1729/psbt_again
Psbt hash preimages (again)
2020-11-05 17:49:58 +00:00
Andrew Poelstra 8295885e8e
Merge pull request #454 from jrawsthorne/improved-bip158-types
Implement new FilterHeader type to differentiate from FilterHash
2020-11-05 16:46:50 +00:00
Andrew Poelstra 93df7cbd3e
Merge pull request #291 from kallewoof/2019-07-signet
add signet support
2020-10-26 19:46:10 +00:00
Steven Roose 9699c622fc
Return Result<(), io::Error> from PublicKey::write_into 2020-10-23 21:31:12 +01:00
Steven Roose 90e1125eff
Remove debug_assert in PublicKey::write_into 2020-10-23 21:28:46 +01:00
Steven Roose cc095a4ba7
Remove assert in Uint256::from_i64 and return None instead 2020-10-23 21:28:15 +01:00
Steven Roose 5c04a059d5
Change some static assertions to debug_assert 2020-10-23 21:28:13 +01:00
Andrew Poelstra e7980ac8a5
Merge pull request #413 from stevenroose/message-signature
Add MessageSignature type for dealing with signed messages
2020-10-14 16:30:15 +00:00
Steven Roose 3f65fb1aed
Don't support signed messages with p2wpkh addresses 2020-10-14 16:54:58 +02:00
Dr Maxim Orlovsky 00c3466363
Serde implementation for PSBT 2020-10-14 16:31:24 +02:00
sanket1729 57b63d4b52 Add tests for psbt hash serde 2020-10-11 21:51:03 -05:00
sanket1729 48151ef204 Added Hash preimages to psbt
Added hash preimages to psbt as per updated bip174
2020-10-11 21:51:02 -05:00
Steven Roose f7422fb8d1
Add MessageSignature type for dealing with signed messages 2020-10-11 22:44:00 +02:00
Alexis Sellier 210ff9edc7
Derive useful traits on `BlockFilter` 2020-10-11 22:31:32 +02:00
Jake Rawsthorne eeb14c4b08 Implement new FilterHeader type to differentiate from FilterHash 2020-10-10 20:38:10 +01:00
Steven Roose e60bfe2f61
Revert the sighash method signatures
Hash engines don't product I/O errors, so encoding into them
shouldn't produce errors either.
2020-10-09 16:27:38 +02:00
Andrew Poelstra 3618d7a41d
Merge pull request #485 from ipaljak-tbtl/expose-tx-signature-data
Expose serialized data for transaction signatures
2020-10-09 13:24:51 +00:00
Ivan Paljak e66caab956 Improve error handling, fix forgotten early return 2020-10-08 16:40:30 +02:00
Elichai Turkel eda47c31c9
Remove redundant code / configurations 2020-10-08 17:11:18 +03:00
Elichai Turkel 2d70623356
Remove deprecated Error::description impl 2020-10-08 17:11:18 +03:00
Elichai Turkel 023fae1f65
Add the dyn keyword where appropriate 2020-10-08 17:11:16 +03:00
Elichai Turkel efe1a55819
Use new inclusive range syntax 2020-10-08 17:08:51 +03:00
Elichai Turkel ad0064db14
Remove hex as a dev-dependency 2020-10-08 17:08:48 +03:00
Andrew Poelstra 7c47c9a341
Merge pull request #356 from elichai/2019-12-macros
Simplifying macros
2020-10-08 14:05:23 +00:00
Elichai Turkel fdd6f4f196
Derive macros instead of implementing via macro_rules 2020-10-08 16:17:14 +03:00
Riccardo Casatta 8ac3af68a4
use u128 in map_to_range 2020-10-08 08:57:59 +02:00
Ivan Paljak c21dabb824 Expose serialized data for transaction signatures 2020-10-08 01:21:10 +02:00
Andrew Poelstra 8c82129442
Merge pull request #480 from LNP-BP/feat/keysource
Introducing `bip32::KeySource`: wrapper for `(Fingerprint, DerivationPath)`
2020-10-07 22:23:39 +00:00
Andrew Poelstra 3748e8faf5
Merge pull request #459 from sgeisler/2020-08-extend-derivation-path
Allow easy concatenation of bip32 derivation paths
2020-10-07 21:34:17 +00:00
Steven Roose d92ca87c69
Merge pull request #488 from sgeisler/2020-10-bip32-doc-fix
Bip32 documentation fix
2020-10-07 21:15:14 +02:00
Sebastian Geisler b8c7bc8dcb Bip32 documentation fix 2020-10-07 16:50:27 +02:00
Karl-Johan Alm a3d9899cb1
add signet support 2020-09-18 16:32:33 +09:00
Dr Maxim Orlovsky c098dfa7f2 BIP32 KeySource refactored to type aliace 2020-09-14 00:37:29 +02:00
Dr Maxim Orlovsky aa67f10162 Introducing `bip32::KeySource`: wrapper for `(Fingerprint, DerivationPath)` 2020-09-13 22:49:52 +02:00
Dr Maxim Orlovsky ff1b4a8dbd WPubkeyHash constructor failing on uncompressed PublicKey 2020-09-11 15:43:05 +02:00
Dr Maxim Orlovsky 1d9f531581 Pubkey hash functions (normal and witness) 2020-09-11 15:04:26 +02:00
Andrew Poelstra c94295c3a9
Revert "Added hash Preimages to psbt" 2020-09-11 11:31:10 +00:00
Andrew Poelstra 3f33bd74e4
Merge pull request #465 from sanket1729/psbt_updates
Added hash Preimages to psbt
2020-09-11 11:30:27 +00:00
Andrew Poelstra 49e97cca65
Merge pull request #387 from pandoracore/builder-p2wildcard
Refactoring script generating functions into a single place
2020-09-11 11:29:09 +00:00
sanket1729 c1eafff9ef Added Sighash calculation for psbt 2020-09-11 01:01:33 -05:00
Andrew Poelstra 05f3451b10 un-deperate contracthash during testing
Avoids a rust test runner bug, see https://github.com/rust-lang/rust/issues/47238
2020-09-10 16:40:31 +00:00
Andrew Poelstra 4e737f708a
Merge pull request #461 from TheBlueMatt/2020-08-mut-sighash
Expose the witnesses of the tx being hashed in SigHashCache
2020-09-10 13:04:51 +00:00
Dr Maxim Orlovsky 38a412c4d5 Fixing review comments for script generators refactoring 2020-09-10 14:44:44 +02:00
Dr Maxim Orlovsky 9143fd3888 All script generation functionality moved to standalone methods in Script 2020-09-10 12:09:04 +02:00
Sebastian Geisler 202a946fc3 Allow easy concatenation of bip32 derivation paths
Currently one has to convert the path into a Vec<ChildNumber>, extend it and finally convert it back again.
2020-09-09 21:42:27 +02:00
sanket1729 e97dda0ffe Add tests for psbt serde 2020-09-09 12:53:09 -05:00
Andrew Poelstra addb54ffc7
Merge pull request #458 from braydonf/version
Transaction and header version is signed int
2020-09-09 17:06:31 +00:00
Andrew Poelstra 5fd91ca2d8
Merge pull request #451 from stevenroose/deprecate-contracthash
Deprecate the util::contracthash module
2020-09-09 17:02:19 +00:00
Andrew Poelstra c8633b5bce
Merge pull request #436 from LNP-BP/feat-u256u8
Big integers (Uint*) from byte slice array with `from_be_bytes`
2020-09-09 16:42:32 +00:00
Andrew Poelstra 45da3add10
Merge pull request #428 from stevenroose/no-witness-uncompressed
Don't allow uncompressed pks in witness addresses
2020-09-09 16:37:06 +00:00
Elichai Turkel a44ba2d878
Merge pull request #397 from stevenroose/script-iter
Improve the Instructions iterator for scripts
2020-09-09 19:06:05 +03:00
Dr. Maxim Orlovsky 42bf893d8b
Update big int from_be_bytes with iterators
Co-authored-by: Sebastian <geisler.sebastian@googlemail.com>
2020-09-03 16:42:00 +02:00
sanket1729 c5204c001f Added Hash Preimages to psbt
Added hash preimages to psbt as per updated bip174
2020-08-31 17:22:40 -05:00
Matt Corallo 3d80a0c962 Expose the witnesses of the tx being hashed in SigHashCache
See docuemntation of the new method for more, but this allows
certain use patterns which were broken with the introduction of
SigHashCache.
2020-08-26 11:18:14 -04:00
Braydon Fuller e9f1f11c2c
Transaction and header version is signed int 2020-08-17 10:28:51 -07:00
Dr Maxim Orlovsky 2fd353d5ab Big integers (Uint*) from byte slice array with `from_be_bytes` 2020-08-09 18:00:00 +02:00
Elichai Turkel e8bcde4d38
Merge pull request #403 from LNP-BP/fix-macro-ns
Hygiene/single code style for all existing macros
2020-08-09 18:16:36 +03:00
Steven Roose c03d2d59c6
Merge pull request #445 from elichai/2020-07-divmod
Use the remainder from div_rem instead of recomputing it
2020-08-09 16:59:39 +02:00
Roman Zeyde 0a25d87f2e Remove empty code block 2020-08-07 14:48:46 +02:00
Steven Roose 1ffdce99ed
Deprecate the util::contracthash module 2020-08-06 12:24:08 +02:00
Elichai Turkel 478e091af6
Merge pull request #443 from sgeisler/2020-06-bip32-derive-more
Derive more traits to use for bip32 Types
2020-07-23 11:24:50 +03:00
Elichai Turkel c20d356d7e
Use the remainder from div_rem instead of recomputing it 2020-07-22 12:39:32 +03:00
Dr Maxim Orlovsky 257ca8e504 Using :: for std namespaces in macro 2020-07-21 22:28:05 +02:00
Dr Maxim Orlovsky f6aa8853a0 Namespace hygiene for macros.rs 2020-07-21 22:28:05 +02:00
Dr Maxim Orlovsky 3a5e8d8504 Namespace hygiene for internal macros 2020-07-21 22:25:59 +02:00
Dr Maxim Orlovsky 7588b211ff Adding Rem op (%) to Uint128 & Uint256 types 2020-07-21 14:37:21 +02:00
Sebastian Geisler a3bb03eeb9 Derive more traits to use DerivationPath in rust-miniscript 2020-07-20 16:52:18 +02:00
Elichai Turkel f4e26caa94
Merge pull request #415 from shesek/merkleblock-txids
Allow to construct MerkleBlock using the header and txids
2020-05-24 16:32:17 +03:00
Steven Roose ed9bf41ff5
Don't allow uncompressed pks in witness addresses 2020-05-23 23:20:46 +01:00
Steven Roose 59b5a73a55
Fix typo and minor formatting in address::Error 2020-05-23 23:20:19 +01:00
Andrew Poelstra 7efde3ae47
Merge pull request #419 from elichai/2020-03-description
Deprecate Error::description
2020-05-23 17:26:38 +00:00
Elichai Turkel af31017eb1
Remove the cursor overhead, write is implemented on vec these days 2020-05-19 12:57:39 +03:00
Elichai Turkel 654232a3dc
Deprecate Error::description 2020-04-13 02:15:28 +03:00
Elichai Turkel 25cb3d3539
Remove alloc when hashing for Bitcoin message signing format 2020-04-12 19:04:13 +03:00
Steven Roose fea09a0a94
Improve the Instructions iterator for scripts
- Rename the `iter` method to `instructions`.
- Add `instructions_minimal` for minimal-enforced iteration.
- Iterator has `Result<Instruction, Error>` as items.
2020-04-11 23:52:26 +01:00
Elichai Turkel 2cc88a99aa
Removed PartialEq,PartialOrd impls, shouldn't be manually impl when Hash is derived 2020-03-29 17:15:15 +03:00
Elichai Turkel a473d01b17
Made some idiomatic changes 2020-03-29 17:15:15 +03:00
Elichai Turkel 3f2d428706
Remove needless references 2020-03-29 17:15:14 +03:00
Elichai Turkel 16eb81e1f7
Replaced slow vec initialization, and dual calls to hashmap 2020-03-29 17:10:27 +03:00
Nadav Ivgi 65efc5cd37 Allow to construct MerkleBlock using the header and txids
Co-Authored-By: Elichai Turkel <elichai.turkel@gmail.com>
2020-03-21 18:23:08 +02:00
Steven Roose 6186ee6269
Change Amount Debug impl to BTC with 8 decimals 2020-03-07 19:52:16 +00:00
Elichai Turkel 07b30c7fac
Mutation testing: amount: Added tests to fix mutation misses 2020-02-23 15:59:26 +02:00
Elichai Turkel ab6e20c87e
Fix an overflow bug in SignedAmount to_string/fmt 2020-02-23 15:59:26 +02:00
Elichai Turkel abc70781e7
Fix a logic problem in base58 (isn't a real bug) 2020-02-23 15:59:26 +02:00
Elichai Turkel 1d01262d5c
Mutation testing: base58: Added tests to "fix" mutation misses 2020-02-23 15:59:26 +02:00
Andrew Poelstra a2bfcb5a89
Merge pull request #395 from pandoracore/fix-construct_uint
Improving `construct_uint` macro
2020-01-24 19:39:32 +00:00
Andrew Poelstra 659f2edb3b
Merge pull request #381 from elichai/2020-01-hex
Remove the hex dependency
2020-01-24 19:14:20 +00:00
Steven Roose 930a6ca1dc
Merge pull request #390 from instagibbs/bip143_sighash_notall
Add bip143 sighash support for other flags
2020-01-21 23:26:17 +00:00
Gregory Sanders d1c5c7b08d Deprecate SigHashComponents 2020-01-21 09:50:41 -05:00
Gregory Sanders 908aff50bc Add bip143 sighash support for other flags 2020-01-21 09:50:41 -05:00
Dr Maxim Orlovsky f3e762b555 Improving `construct_uint` macro 2020-01-21 13:16:34 +01:00
Elichai Turkel c19b736566
Remove the hex dependency 2020-01-20 18:50:02 +02:00
Steven Roose 8e52b8ce4d
Remove the BitcoinHash trait
Replaced by a `block_hash` method on both `Block` and `BlockHeader`.
2020-01-10 11:34:16 +00:00
Dr Maxim Orlovsky 5fc24dea33 Multiple fixes for hash types and their computing
Unit test for wtxid and SegWit transactions
2020-01-01 13:54:23 +01:00
Dr Maxim Orlovsky 0abe15b1f6 Moving from BitcoinHash to Wtxid for Transactions 2020-01-01 13:52:20 +01:00
Dr Maxim Orlovsky f5a8087105 New hash types: MerkleRoot/Branch, WitnessCommit, SigHash, FilterHash 2020-01-01 13:50:17 +01:00
Dr Maxim Orlovsky d20ab1dbc4 Switching to XpubIdentifier 2020-01-01 13:46:44 +01:00
Dr Maxim Orlovsky 5f4f629bb1 Replaced all hash160, sha256 and sha256d with the new hash types throughout the code
Embedding Txid's in the doc exaples
2020-01-01 13:44:34 +01:00
Dr Maxim Orlovsky 5ef39e34fa Implementing (W)Pubkey/ScriptHash and BlockHash 2020-01-01 13:42:22 +01:00
Dr Maxim Orlovsky ec92a05682 New HashTypes defined according to #284 (WIP), Txid is completed 2020-01-01 13:41:42 +01:00
Steven Roose 5f4555bfac
Remove util::misc::hex_bytes in favor of bitcoin_hashes::hex 2019-12-09 14:19:09 +00:00
Steven Roose 0469453da6
Use psbt::Error in PartiallySignedTransaction::from_unsigned_tx 2019-12-09 14:19:07 +00:00
Steven Roose 725884bab5
Introduce key::Error 2019-12-09 14:17:39 +00:00
Matt Corallo acb43af981 Drop byteorder dependency
Taking an external dependency just to convert ints to byte arrays
is somewhat of a waste, especially when Rust isn't very aggressive
about doing cross-crate LTO.

Note that the latest LLVM pattern-matches this, and while I haven't
tested it, that should mean this means no loss of optimization.
2019-12-05 10:41:00 -05:00
Matt Corallo f1f7718b6c Drop (non-test/serde) hex dep in favor of bitcoin_hashes' fn's 2019-12-05 10:40:59 -05:00
Tamas Blummer 9f3e355c5c upgrade to secp256k1 0.15 and bitcoinconsensus 0.17 2019-08-21 19:04:40 +02:00
Elichai Turkel 52ff97cddc
Deny unused imports and remove unneeded 2019-08-19 13:29:43 -04:00
Steven Roose c01172780b
Re-export bitcoin_hashes and secp256k1 dependency 2019-08-16 15:52:58 +01:00
Steven Roose 48f4c1989f
Rename bitcoin_hashes dependency to hashes 2019-08-16 15:52:27 +01:00
Steven Roose 09a65023a2
Add tests for p2shwpkh and p2shwsh 2019-08-15 22:29:09 +01:00
Steven Roose 170abaa82f
Use the new bech32 functions 2019-08-15 22:29:06 +01:00
Steven Roose 3a93f8522c
Format address module 2019-08-15 22:28:46 +01:00
Steven Roose 8de13a3915
Redo the BIP-173 test vectors
Before, non-version-zero segwit addresses were not included.
2019-08-15 22:28:27 +01:00
Steven Roose e469fec839
address: Drop error::Error::description impl 2019-08-15 22:28:25 +01:00
Steven Roose bfdcfee28e
Add Address::from_script constructor 2019-08-15 22:28:20 +01:00
Steven Roose 33e8ba3c7e
Extract roundtrip method from Address tests 2019-08-13 08:47:17 +01:00
Steven Roose 8804a41f1f
Add AddressType enum 2019-08-13 08:47:15 +01:00
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
Steven Roose b23de17d55 bip32: Introduce DerivationPath type
Implements Display and FromStr for easy usage with serialized types.
2019-02-14 11:09:34 +00:00
Steven Roose a80cea270a bip32: ChildNumber constructors return Result
They can produce an error if the index is out of range.
2019-02-14 11:08:13 +00:00
Carl Dong a944c7fbd0 key: Use correct error for decoding
This change also moves the secp256k1::Error wrapper from util::Error to
consensus::encode::Error, since we do not use it anywhere else. We can
add it back to util::Error once we have instances of secp256k1::Error
that are not related to consensus::encode.
2019-02-11 15:15:03 -05:00
Carl Dong fc448ba47c key: Reword and clarify comments 2019-02-11 15:10:20 -05:00
Carl Dong b3cc3d50ef Integrate newly-added PublicKey with Address
- Switch util::address::Payload::Pubkey variant to wrap
  util:🔑:PublicKey
- Switch util::address::Address::p*k* constructors to use
  util:🔑:PublicKey
- Fix tests for aforementioned switch
- Add convenience methods for util:🔑:PublicKey to
  util:🔑:PrivateKey conversion
- Switch BIP143 tests to use util:🔑:PublicKey
2019-02-11 15:10:13 -05:00
Carl Dong 53a6efe33c Add PublicKey struct encapsulating compressedness
- Move util::privkey to util::key
- Add PublicKey struct to util::key
- Implement de/serialization methods for util:🔑:PublicKey
2019-02-11 14:56:55 -05:00
Carl Dong 60c93c387f Cleanup util::privkey in preparation for PublicKey
- Rename privkey::PrivKey to privkey::PrivateKey
- Remove unnecessary methods for privkey::PrivateKey
- Modify tests to work with above changes
2019-02-11 14:56:49 -05:00
Steven Roose f80e882813
Remove Address::p2pk
There is no address format for p2pk.
2019-02-07 20:02:21 +00: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 c830fb4629 Remove code deprecated by bitcoin_hashes from util::hash 2019-01-24 16:27:52 -05: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