Andrew Poelstra
9fe840c20e
Merge pull request #644 from sanket1729/tap_opcodes
...
Add OP_CHECKSIGADD and OP_SUCCESSxxx
2021-09-24 22:47:48 +00:00
Antoine Poinsot
826fed53f2
transactions: add a note about `get_vsize` and standardness rules
...
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-09-24 19:48:36 +02:00
Dr Maxim Orlovsky
c1991d748f
Improving error information for address parser
2021-09-21 12:45:17 +02:00
Clark Moody
eeeb722155
Bump bech32 to 0.8.0 and use BIP-0350 Bech32m checksum
...
Replace BIP-0173 test vectors with those in BIP-0350.
2021-09-21 12:45:17 +02:00
Dr Maxim Orlovsky
5573a546ca
Taproot P2TR address
2021-09-21 12:45:17 +02:00
Martin Habovstiak
083f5f3138
Document lack of support for 16-bit pointers
...
This clearly states lack of support for 16-bit architectures as well as
adds readable `compile_error!()` call. It also fixes a few stylistic
mistakes - headings (top-level should not be repeated) and missing
newlines.
Closes #660
2021-09-20 21:31:46 +02:00
Andrew Poelstra
29549ccc73
Merge rust-bitcoin/rust-bitcoin#658 : Check for overflow in Script::bytes_to_asm_fmt()
...
76cf74fa9b
Added test for the overflow bug and few others (Martin Habovstiak)
a0e1d2e706
Check for overflow in Script::bytes_to_asm_fmt() (Martin Habovstiak)
Pull request description:
This adds an overflow check in `Script::bytes_to_asm_fmt()` motivated by
`electrs` issue. While it was not tested yet, I'm very confident that
overflow is the cause of panic there and even if not it can cause panic
becuase the public function takes unvalidated byte array and reads
`data_len` from it.
The `electrs` issue: https://github.com/romanz/electrs/issues/490
~~Strangely, this breaks a test case and I can't see why. I'm publishing in case someone wants to help.~~
Edit: One damn character. :D Should be OK now.
ACKs for top commit:
apoelstra:
ACK 76cf74fa9b
Tree-SHA512: 4ffeca442a71b10c132f055f056128ae64e66cbdc1891662c3a4e743b82fa5d27075a44513e844be37888b33068eef3bbf6bcced5def70c17c9c5bd5b9d870cc
2021-09-20 14:22:44 +00:00
Martin Habovstiak
76cf74fa9b
Added test for the overflow bug and few others
...
This adds a test case for script formatting which caused overflow in the
past and a few others from the same "interesting" transaction. Note that
to trigger the bug one has to run the test on 32 bit architecture.
2021-09-19 15:45:17 +02:00
Martin Habovstiak
a0e1d2e706
Check for overflow in Script::bytes_to_asm_fmt()
...
This adds an overflow check in `Script::bytes_to_asm_fmt()` motivated by
`electrs` issue. While it was not tested yet, I'm very confident that
overflow is the cause of panic there and even if not it can cause panic
becuase the public function takes unvalidated byte array and reads
`data_len` from it.
The `electrs` issue: https://github.com/romanz/electrs/issues/490
2021-09-19 13:33:37 +02:00
Dr Maxim Orlovsky
55c627715f
Moving globals into PSBT struct
2021-09-16 12:34:04 +02:00
Dr. Maxim Orlovsky
b7f984972a
Merge pull request #655 from vss96/Limit-Script-Size
2021-09-16 10:42:08 +02:00
Andrew Poelstra
b6b60fc4aa
Merge rust-bitcoin/rust-bitcoin#628 : Adds Taproot BIP341 signature message and create a unified sighash cache for legacy, segwit and taproot inputs
...
c704ee7ffe
[docs-only] Use backtick in addition to square parentheses for types references, clarify legacy, non_exhaustive comment, remove std:: (Riccardo Casatta)
f223be618f
Rename access_witness to witness_mut and return Option (Riccardo Casatta)
c9bc0b928a
[fmt-only] autoformatting with `rustfmt src/util/sighash.rs` (Riccardo Casatta)
07774917c2
Use get_or_insert_with in segwit_cache (Martin Habovstiak)
497dbfb7c3
Use get_or_insert_with in common_cache() (Martin Habovstiak)
ca80a5a030
Use get_or_insert_with in taproot_cache (Martin Habovstiak)
6e06a32ccc
Wrap ErrorKind in Io enum variant, fix doc comment for the IO variant (Riccardo Casatta)
1a2b54ff23
introduce constant KEY_VERSION_0 (Riccardo Casatta)
417cfe31e3
Derive common traits for structs and enum, make internal struct not pub (Riccardo Casatta)
55ce3dd6ae
Fix validation error if SINGLE with missing corresponding output, remove check_index and check with get().ok_or(), more details in errors (Riccardo Casatta)
2b3b22f559
impl Encodable for Annex to avoid allocation (Riccardo Casatta)
1a7afed068
Add Reserved variant to SigHashType for future use (ie SIGHASH_ANYPREVOUT) (Riccardo Casatta)
53d0e176d3
Deprecate bip143::SigHashCache in favor of sighash::SigHashCache (Riccardo Casatta)
15e3caf62d
[test] Test also sighash legacy API with legacy tests (Riccardo Casatta)
24acfe3672
Implement Bip341 signature hash, create unified SigHashCache for taproot, segwit and legacy inputs (Riccardo Casatta)
683b9c14ff
add [En|De]codable trait for sha256::Hash (Riccardo Casatta)
Pull request description:
Adds https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki message signature algorithm
The base is taken from `bip143::SigHashCache`, some code results duplicated but I think it's more clear to keep things separated
Would mark some bullet point on https://github.com/rust-bitcoin/rust-bitcoin/issues/503
Test vectors are taken by running d1e4c56309/test/functional/feature_taproot.py
with a modified `TaprootSignatureHash` function to print intermediate values that I cannot found in the bip341 [test vector json](https://raw.githubusercontent.com/bitcoin-core/qa-assets/main/unit_test_data/script_assets_test.json )
UPDATE: Latest version includes the suggestion from @sanket1729 to create a unified tool for signature message hash for legacy, segwit, and taproot inputs. In particular, makes sense for mixed segwit v0 and taproot v1 inputs because cached values could be shared
ACKs for top commit:
sanket1729:
ACK c704ee7ffe
. Reviewed the diff from a37de1ade475e0c31c932121abaa7aec701b9987 which I previously ACKed
dr-orlovsky:
utACK c704ee7ffe
by diffing it to 6e06a32ccc
having my ACK before.
apoelstra:
ACK c704ee7ffe
Tree-SHA512: 35530995fe9d078acd0178cfca654ca980109f4502c91d578c1a0d5c6cafacab7db1ffd6216288eac99f6a763776cbc0298cfbdff00b5a83e98ec4b15aa764e8
2021-09-15 17:47:17 +00:00
Vikas S Shetty
48c732e934
Changes for checking script size and returning Error appropriately
2021-09-15 16:16:20 +05:30
Dr Maxim Orlovsky
c75f3ef4a8
Handling CHECKMULTISIG(VERIFY) ops in TapScript context; refactoring classifier
2021-09-14 13:58:16 +02:00
Martin Habovstiak
95fb4e01f9
Document cargo features
...
This documents cargo features in two ways: explictly in text and in code
using `#[doc(cfg(...))]` attribute where possible. Notably, this is
impossible for `serde` derives. The attribute is contitional and only
activated for docs.rs or explicit local builds.
This change also adds `package.metadata.docs.rs` field to `Cargo.toml`
which instructs docs.rs to build with relevant features and with
`docsrs` config activated enabling `#[doc(cfg(...))] attributes.
I also took the opportunity to fix a few missing spaces in nearby code.
2021-09-14 12:24:57 +02:00
Ben Carman
894f0f09b6
Add Bloom filter network messages
...
Co-authored-by: jrawsthorne <jake@jakerawsthorne.co.uk>
2021-09-13 15:08:38 -05:00
sanket1729
b0ad6748e4
Add tests for opcode classification
2021-09-13 07:45:15 -07:00
sanket1729
c252b36786
Add CHECKSIGADD and update classify API
2021-09-13 07:45:00 -07:00
Dr Maxim Orlovsky
d20669522e
Fixing no_std for Amount sum iterator
2021-09-13 10:36:07 +02:00
Dr. Maxim Orlovsky
b2c8a7ebc1
Merge pull request #615 from sgeisler/2021-06-sum-amounts
...
Implement `Sum` for amount types
2021-09-11 00:11:15 +02:00
Dr. Maxim Orlovsky
697e8f5194
Merge pull request #626 from visvirial/impl-vsize
...
Implement `Block.get_strippedsize()` and `Transaction.get_vsize()`
2021-09-11 00:09:22 +02:00
Andrew Poelstra
13a6c3b4d6
Merge rust-bitcoin/rust-bitcoin#625 : Improvements to Error types (part 4)
...
994079b099
Refactoring error variants: removing unused; better names & inner types (Dr Maxim Orlovsky)
Pull request description:
Removes controversial aspects from #560 (all `io::Error`-related changes) and leaves the rest
ACKs for top commit:
sanket1729:
ACK 994079b099
apoelstra:
ACK 994079b099
Tree-SHA512: 020e49193c885e862f45e5f7baabf1d22a3ec09e78fd7f573b2f3d327beb4f91683951ba080b3d804e8337a188dcad0f38ba70ee8059aef0681a0b2bba0a2140
2021-09-08 21:22:32 +00:00
Andrew Poelstra
2a655f4b58
Merge pull request #617 from LNP-BP/feat/witness-version
...
WitnessVersion type
2021-09-08 20:58:57 +00:00
Riccardo Casatta
c704ee7ffe
[docs-only] Use backtick in addition to square parentheses for types references, clarify legacy, non_exhaustive comment, remove std::
2021-08-31 13:58:48 +02:00
Riccardo Casatta
f223be618f
Rename access_witness to witness_mut and return Option
...
fix the example in sighash to refer to sighash::SigHashCache instead of bip143::SigHashCache
2021-08-31 13:55:52 +02:00
Riccardo Casatta
c9bc0b928a
[fmt-only] autoformatting with `rustfmt src/util/sighash.rs`
2021-08-31 13:54:41 +02:00
Sanket Kanjalkar
bd5d875e8a
Merge pull request #623 from RCasatta/fixdoc
...
Fix documentation referencing macro var
2021-08-12 18:38:07 -07:00
Martin Habovstiak
07774917c2
Use get_or_insert_with in segwit_cache
...
This refactors the code to make it possible to use `get_or_insert_with`
instead of unwrapping in `segwit_cache()`. To achieve it `common_cache`
is refactored into two functions: one taking only the required borrows
and the original calling the new one. `segwit_cache` then calls the new
function so that borrows are OK.
Apart from removing unwrap, this avoids calling `common_cache` multiple
times.
2021-08-10 10:36:51 +02:00
Dr Maxim Orlovsky
ecc400826c
Updating Script::is_witness_program to use new WitnessVersion
2021-08-10 10:34:15 +02:00
Dr Maxim Orlovsky
64c1ec0b76
WitnessVersion type
2021-08-10 10:34:15 +02:00
Martin Habovstiak
497dbfb7c3
Use get_or_insert_with in common_cache()
...
There was a question whether this is equally performant. There are
multiple good reasons why it should be:
1. `get_or_insert_with` is marked `#[inline]`
2. Any good optimizer will inline a function that is used exactly once
3. 1 and 2 conclude that the closure will get inlined
4. Computing self.tx can then be moved to the only branch where it is
required.
5. Even if get_or_insert_with didn't get optimized, which is extremely
unlikely, the `tx` field is at the beginning of the struct and it
probably has pointer alignment (`Deref` suggests it's a pointer).
Alignment larger than pointer is not used, so we can expect the
fields to be ordered as-defined. (This is not guaranteed by Rust but
there's not good reason to change the order in this case.) We can
assume that offset to tx is zero in most cases which means no
computation is actually needed so the expression before closure is
no-op short of passing it into the closure as an argument.
At the time of writing `#[inline]` can be seen at
https://doc.rust-lang.org/src/core/option.rs.html#933
2021-08-10 10:20:41 +02:00
Martin Habovstiak
ca80a5a030
Use get_or_insert_with in taproot_cache
2021-08-10 10:02:33 +02:00
Dr. Maxim Orlovsky
4e3c2c32fc
Merge pull request #632 from tcharding/prefixes
2021-08-09 23:26:15 +02:00
Dr. Maxim Orlovsky
8ae030b951
Merge pull request #618 from elsirion/possible_networks
2021-08-09 23:25:06 +02:00
Dr. Maxim Orlovsky
33393e0bf4
Merge pull request #621 from RCasatta/verify_with_amount
2021-08-09 23:23:09 +02:00
Dr. Maxim Orlovsky
808e1708c3
Merge pull request #596 from RCasatta/script_ser
2021-08-09 23:22:06 +02:00
Dr Maxim Orlovsky
994079b099
Refactoring error variants: removing unused; better names & inner types
2021-08-01 21:08:39 +02:00
Tobin Harding
adc1543e7c
Use consts for address prefix values
...
Instead of using magic numbers we can define constants for the address
prefix bytes. This makes it easier for future readers of the code to see
what these values are if they don't know them and/or see that they are
correct if they do know them.
2021-07-22 10:31:14 +10:00
Riccardo Casatta
6e06a32ccc
Wrap ErrorKind in Io enum variant, fix doc comment for the IO variant
2021-07-21 12:07:12 +02:00
Riccardo Casatta
1a2b54ff23
introduce constant KEY_VERSION_0
2021-07-21 12:07:10 +02:00
Riccardo Casatta
417cfe31e3
Derive common traits for structs and enum, make internal struct not pub
2021-07-21 12:07:08 +02:00
Riccardo Casatta
55ce3dd6ae
Fix validation error if SINGLE with missing corresponding output, remove check_index and check with get().ok_or(), more details in errors
2021-07-21 12:07:05 +02:00
Riccardo Casatta
2b3b22f559
impl Encodable for Annex to avoid allocation
2021-07-21 12:07:00 +02:00
Riccardo Casatta
1a7afed068
Add Reserved variant to SigHashType for future use (ie SIGHASH_ANYPREVOUT)
2021-07-21 12:05:42 +02:00
Riccardo Casatta
53d0e176d3
Deprecate bip143::SigHashCache in favor of sighash::SigHashCache
2021-07-21 12:05:40 +02:00
Riccardo Casatta
15e3caf62d
[test] Test also sighash legacy API with legacy tests
2021-07-21 12:05:37 +02:00
Riccardo Casatta
24acfe3672
Implement Bip341 signature hash, create unified SigHashCache for taproot, segwit and legacy inputs
2021-07-21 12:05:18 +02:00
Riccardo Casatta
683b9c14ff
add [En|De]codable trait for sha256::Hash
2021-07-21 10:36:06 +02:00
Andrew Poelstra
df4d70a37e
Merge pull request #627 from RCasatta/bigendian
...
Bigendian fixes and CI test
2021-07-20 20:56:16 +00:00
Devrandom
4826d0c6cc
no_std support
...
Based on the original work by Justin Moon.
*MSRV unchanged from 1.29.0.*
When `std` is off, `no-std` must be on, and we use the [`alloc`](https://doc.rust-lang.org/alloc/ ) and core2 crates. The `alloc` crate requires the user define a global allocator.
* Import from `core` and `alloc` instead of `std`
* `alloc` only used if `no-std` is on
* Create `std` feature
* Create `no-std` feature which adds a core2 dependency to polyfill `std::io` features. This is an experimental feature and should be
used with caution.
* CI runs tests `no-std`
* MSRV for `no-std` is 1.51 or so
2021-07-15 09:04:49 +02:00
Riccardo Casatta
11d5a30f86
comment only: explain reason for swap bytes
2021-07-02 12:05:09 +02:00
Riccardo Casatta
0f4d2cfcaa
swap bytes in network code instead of swapping only in little-endian
2021-06-29 16:01:34 +02:00
Riccardo Casatta
8996249f2d
remove {to/from}_le from impl_int_encodable
...
they are a noop on little-endian and the following {to/from}_array_le are sufficient to deal with big-endian
2021-06-29 15:57:31 +02:00
Vis Virial
cdf7be4765
Add extra checks for `test_segwit_transaction()`.
2021-06-29 07:59:22 +09:00
Vis Virial
2bda871628
Remove `#[inline]` from `Transaction.get_strippedsize()`.
2021-06-29 07:40:13 +09:00
Vis Virial
c9dead410a
Implement `Transaction.get_strippedsize()`.
...
`Block.get_strippedsize()` is also simplified and optimized.
2021-06-29 07:34:37 +09:00
Vis Virial
1bf9147a6e
Optimize `Transaction.get_vsize()` (thanks @TheBlueMatt).
2021-06-29 07:14:01 +09:00
Vis Virial
2085dc32a7
Refactoring: define `Block.get_base_size()`.
2021-06-28 20:07:07 +09:00
Vis Virial
4ac9cef9e9
Implement `Block.get_strippedsize()` and `Transaction.get_vsize()`.
2021-06-28 20:03:42 +09:00
elsirion
94229ae964
Implement is_valid_for_network function for Address
2021-06-26 19:34:33 +02:00
Riccardo Casatta
8f27579c7f
fix documentation referencing macro var
2021-06-25 09:56:40 +02:00
Sebastian Geisler
4dae56908b
Seal `CheckedSum`
2021-06-23 15:14:24 +02:00
Riccardo Casatta
a86bced568
use Amount type in verify
2021-06-21 14:43:09 +02:00
Andrew Poelstra
abff973e83
Merge pull request #601 from LNP-BP/feat/bech32m-1
...
Bech32m adoption
2021-06-18 21:14:12 +00:00
Sebastian
e334c9deea
Merge pull request #616 from sgeisler/2021-06-dust-value-amount
...
Use `Amount` type for dust value calculation
2021-06-16 20:51:23 +02:00
Riccardo Casatta
4a4460b1a3
Add test for script serialize/deserialize
2021-06-16 10:17:56 +02:00
Riccardo Casatta
fadd368911
use different ser/de for Script in case of non human readable format
2021-06-16 10:17:40 +02:00
Dr Maxim Orlovsky
aa5c36df12
Covering all BIP-173 and BIP-350 test vectors
2021-06-16 08:43:18 +02:00
Sebastian
b0ae2a6842
Merge pull request #521 from RCasatta/errors_enum
...
Errors enum improvements
2021-06-15 14:01:56 +02:00
Riccardo Casatta
88c186e436
nits on display implementation
2021-06-14 12:24:31 +02:00
Riccardo Casatta
c26b3b9679
remove unused RngError, saving 24 bytes
2021-06-13 22:40:55 +02:00
Riccardo Casatta
9613181601
Split invalid version for address and extended key, saving also 16 bytes on the stack
2021-06-13 22:39:32 +02:00
Riccardo Casatta
bace07d8f8
Remove base58::Error::Other variant in favor of specific variant
2021-06-13 22:33:54 +02:00
Riccardo Casatta
0eaf45ca81
Use boxed sliced instead of Vec in InvalidPreimageHashPair variant
2021-06-13 22:33:52 +02:00
Riccardo Casatta
781b0e014a
Box big Transaction type in psbt error
2021-06-13 22:33:48 +02:00
Sebastian Geisler
9981da2ec8
Use `Amount` type for dust value calculation
2021-06-12 21:15:13 +02:00
Sebastian Geisler
6f7da5f2ef
Implement `CheckedSum` for amount types
...
It's just `Sum` with checked arithmetic.
2021-06-12 17:23:30 +02:00
Sebastian Geisler
f28110b31c
implement `Sum` for amount types
...
To be able to sum up iterators of amounts it is
not sufficient that these implement `Add`, they
also need to implement `Sum`.
2021-06-12 17:23:27 +02:00
Devrandom
95aa3bf153
std -> core
2021-06-11 17:28:04 +02:00
Matt Corallo
a15f263c4e
Move the `increment` fn into the uint macro to add it to Uint128
2021-06-08 22:20:36 +00:00
Sebastian Geisler
091ac89440
Fix semver breaking Display change of ChildNumber
...
Fixes #608 . In #567 the Display impl for ChildNumber was
consciously changed, assuming the semver break would not
affect any correctly implemented downstream projects. We
were wrong.
2021-06-08 15:33:02 +02:00
Dr Maxim Orlovsky
c1fae03686
Non-API breaking Bech32m adoption
2021-06-08 08:43:39 +02:00
Dr. Maxim Orlovsky
73f1ed7d4c
Merge pull request #606 from romanz/fix-bip158-format
...
Fix bip158 example formatting
2021-06-06 20:11:22 +02:00
Sebastian
d7eb15c6f1
Merge pull request #584 from darosior/max_tx_weight_const
...
Introduce some policy constants from Bitcoin Core
2021-05-29 02:49:46 +02:00
Roman Zeyde
60e51ada36
Fix bip158 example formatting
2021-05-28 16:01:49 +03:00
Andrew Poelstra
052aaf1d80
Merge pull request #559 from LNP-BP/fix/error-derives-2
...
Fix/error derives 2
2021-05-19 15:02:10 +00:00
Antoine Poinsot
7345aa60d9
policy: add a function to get the virtual transaction size
...
It's very useful to Bitcoin applications, and especially "L2" ones, to
effectively compute feerates. Currently (and this is very unlikely to
change) bitcoind nodes compute the virtual size as a rounded-up division
of the size in witness units by 4, with a penalty for transactions that
are essentially >5% full of sigops.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-05-18 14:53:45 +02:00
Antoine Poinsot
2e9d62a9c7
blockdata/script: use policy's constant in dust computation
...
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-05-18 14:52:58 +02:00
Antoine Poinsot
2b777485fa
policy: introduce p2p constants from the reference implementation
...
This introduces some constants defined by Bitcoin Core which as a
consequence define some network rules in a new 'policy' module.
Only some were picked, which are very unlikely to change. Nonetheless a
Warning has been put in the module documentation.
Script-level constants are left into rust-miniscript where they are
already defined (src/miniscript/limits.rs).
2021-05-18 14:52:56 +02:00
Matt Corallo
05046b58d3
Merge pull request #602 from LNP-BP/fix/core
...
Fixing hashes core dependency and fuzz feature
2021-05-07 19:49:43 +00:00
Andrew Poelstra
e5f37b817d
Merge pull request #581 from RCasatta/qr_string
...
Address to optimized QR string
2021-05-06 17:12:17 +00:00
Andrew Poelstra
4620c640a9
Merge pull request #579 from TheBlueMatt/master
...
Fix Script::dust_value()'s calculation for non-P2*PKH script_pubkeys
2021-05-06 16:01:36 +00:00
Andrew Poelstra
d0fb626baf
Merge pull request #592 from LNP-BP/feat/ecdsa-key-creation
...
Constructors for compressed and uncompressed ECDSA keys
2021-05-06 15:50:06 +00:00
Andrew Poelstra
3fd88d317f
Merge pull request #598 from RCasatta/verify_flags
...
Add verify_with_flags to Script and Transaction
2021-05-05 22:33:47 +00:00
Matt Corallo
fc6f23fb9b
Drop not-very-useful output dust threshold constants
...
It doesn't really make sense to have a constant for every common
script type's dust limit, instead we should just use the
`Script::dust_value()` function to have users calculate it.
2021-05-05 14:53:26 +00:00
Dr Maxim Orlovsky
c0b7defc86
More non-API breaking error derives depending on upstream PRs
2021-05-04 03:58:56 +02:00
Dr Maxim Orlovsky
122450b102
Fixing hashes core dependency and fuzz feature
2021-05-04 03:47:34 +02:00
Riccardo Casatta
c96f7ec71c
use markdown autolink syntax for urls with no text
2021-05-03 13:46:10 +02:00
Riccardo Casatta
c58446f9c1
Deny broken doc intra-links and build docs in CI
2021-05-03 12:07:28 +02:00
Riccardo Casatta
ef471ccca7
Fix documentation, in particular link to code elements
2021-05-03 11:43:11 +02:00
Matt Corallo
15981c945a
Fix Script::dust_value()'s calculation for non-P2*PKH script_pubkeys
...
The dust calculations added were only valid for P2WPKH and P2PKH
outputs, and somehow this fact was missed in review, despite the
upstream Core code being linked to and looked at by two reviewers
and the author (me).
Someday I will grow eyeballs, but that day is not today.
2021-05-01 17:47:45 +00:00
Dr. Maxim Orlovsky
68096242d3
Merge pull request #594 from RCasatta/capped
...
Count bytes read in encoding
2021-05-01 16:28:57 +02:00
Dr Maxim Orlovsky
187eae8a13
Streamlining private key construction API in BIP32
2021-05-01 13:40:21 +02:00
Dr Maxim Orlovsky
18b6bd0d15
Adopting new ECDSA key constructors throughout the library
2021-05-01 13:34:31 +02:00
Dr Maxim Orlovsky
ceacc7d85f
Constructors for compressed and uncompressed ECDSA keys
2021-05-01 13:34:04 +02:00
Riccardo Casatta
69117a1f63
Use Amount for verify_with_flags
2021-05-01 10:22:35 +02:00
Riccardo Casatta
d1f4c0a5c8
Remove Copy for flags parameter
2021-05-01 10:19:54 +02:00
Riccardo Casatta
3aaa5d6846
Add verify with flags
2021-04-30 18:56:35 +02:00
Andrew Poelstra
4db4e604cb
Merge pull request #589 from LNP-BP/taproot/key-1
...
Non-API breaking introduction of Schnorr keys
2021-04-29 20:30:54 +00:00
Riccardo Casatta
f692c4a938
Limit bytes read with Take
2021-04-28 09:33:37 +02:00
Andrew Poelstra
8231e25292
Merge pull request #586 from sanket1729/warn
...
fix warnings for sighashtype
2021-04-21 15:52:44 +00:00
Andrew Poelstra
da477f1041
Merge pull request #558 from LNP-BP/fix/error-derives-1
...
Non-API breaking derives for error & transaction types
2021-04-21 14:24:27 +00:00
Riccardo Casatta
0a91496570
rename to_qr_string into to_qr_uri returning also the schema
2021-04-15 10:40:57 +02:00
Dr Maxim Orlovsky
230813b578
Making old ECDSA key type paths depeicated
2021-04-12 14:18:15 +02:00
Dr Maxim Orlovsky
664b09cdfd
Re-export Scep256k1 Schnorr keys under `util::schnorr`
...
This is second step in introducing Schnorr key support as per #588
2021-04-12 14:18:00 +02:00
Dr Maxim Orlovsky
b17d7fc31c
Moving keys under `util::ecdsa`, re-exporting them at `util::key`
...
This is the first step in introducing Schnorr key support as per #588
2021-04-12 14:17:42 +02:00
Riccardo Casatta
3158cedea0
document alternate formatting
2021-04-11 18:14:28 +02:00
Martin Habovstiak
bc406bfdd6
Use &mut dyn fmt::Write instead of bool
...
This replaces manually-written dynamic dispatch with `&mut dyn
fmt::Write` which is hopefully more readable.
2021-04-09 17:58:35 +02:00
Riccardo Casatta
85ae82febb
use the char trick to avoid allocation
2021-04-07 16:56:54 +02:00
Riccardo Casatta
104836a042
implements alternate formatting for address
2021-04-07 15:49:58 +02:00
sanket1729
3545580bd9
fix warnings for sighashtype
2021-04-06 11:52:14 -07:00
Dr Maxim Orlovsky
7fe3c4a605
Non-API breaking derives for error types
2021-04-06 14:44:50 +02:00
Collins Muriuki
c4cfdbbd6a
doc: correct Transaction struct encode_signing_data_to doc comment
2021-04-03 23:52:09 +03:00
Sebastian
1326f7d2a8
Merge pull request #569 from stevenroose/static-asm
...
Make Script::fmt_asm a static method and add Script::str_asm
2021-03-31 23:45:03 +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
851a3a15c0
Make Script::fmt_asm a static method and add Script::str_asm
...
This makes it convenient to print/construct the script assembly on
byte slices withoout having to clone them to copy them to create a
Script struct.
2021-03-13 22:16:20 +00:00
Steven Roose
96fa4b7d9b
Implement AsRef<[u8]> for Script
2021-03-13 22:13:39 +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
Antoine Poinsot
bf98d9fd60
transaction: add a method to err on non-standard types to SigHashType
...
Right now, any sighash type could be parsed without error, which matches
consensus rules. However most of them would be invalid by standardness,
so it's a bit footgun-y (even more so for pre-signed transactions
protocols for which standardness is critical).
This adds `from_u32_standard()`, which takes care to error if we are
passed an invalid-by-current-policy-rules SIGHASH type.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-02-19 11:12:02 +01:00
Antoine Poinsot
466f161e0b
transaction: document why we mask sighash types with 0x9f
...
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Co-Authored-by: sanket1729 <sanket1729@gmail.com>
2021-02-19 00:27:02 +01:00
Antoine Poinsot
7f73d5f7db
doc: correct SigHashType doc comment
...
Super nit, but a hashtype is not specific to a transaction but a
signature.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-02-18 19:48:39 +01:00
Jeffrey Czyz
ade2bcee8e
Return BlockHash from BlockHeader::validate_pow
...
Validating a block's proof-of-work involves computing the block hash.
Returning it from BlockHeader::validate_pow avoids having callers
recompute the block hash if it is needed.
2021-02-17 17:40:17 -08:00
Dr Maxim Orlovsky
017cd71ca7
Improving bip32 ChildNumber display implementation
2021-02-11 23:06:24 +01:00
Sebastian
5bd61967b2
Merge pull request #566 from TheBlueMatt/2021-02-dust-value
...
Add Script:dust_value() to get minimum output value for a spk
2021-02-07 11:45:17 +01:00
Sebastian
80b47f1f5b
Merge pull request #565 from sgeisler/2021-02-rbf
...
Add function to check RBF-ness of transactions
2021-02-06 16:39:53 +01:00
Matt Corallo
6622de4041
Add Script:dust_value() to get minimum output value for a spk
2021-02-05 15:26:56 -05:00
Sebastian Geisler
e98f14387d
Add function to check RBF-ness of transactions
2021-02-04 22:15:26 +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
f1664db374
Merge pull request #538 from sanket1729/fix_warning
...
Fix service flags warning
2021-01-11 19:26:08 +00:00
Andrew Poelstra
4b58a254c5
encode: add some more generic impls (more tuples, references)
2021-01-08 23:21:55 +00:00
Andrew Poelstra
ffe452ac0b
script: add FromHex and FromStr implementations
2021-01-05 18:45:14 +01:00
Andrew Poelstra
92000bf51b
PublicKey: add read_from method to be symmetric with write_into
2021-01-04 19:07:27 +00:00
Max Giraldo
21b2f929c5
refactor(blockdata/transaction): use nested paths
...
Instead of using a wildcard path for the `hash_types` module,
be explicit about what types we're using by using nested paths.
There are many benefits to this, including not polluting the namespace
and clearly demarcating the types' location.
2021-01-04 00:01:59 +01:00
Max Giraldo
06dc0041c2
docs: fix quotes in Transaction#ntxid description
...
Insert double quotes instead of a combination of single quote
and backtick.
2021-01-01 05:52:23 -08:00
Steven Roose
a8f2faf96d
serde_utils: Only use special serialization for human-readable
...
Non-human-readable serialization (binary) doesn't need hexification.
2020-12-30 16:32:52 +01: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
0ab8823984
Merge pull request #536 from 0xB10C/2020-12-add-blockheader-tests
...
Add BlockHeader tests
2020-12-28 16:56:56 +00: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
0xB10C
b7caf0110f
test: BlockHeader::difficulty()
...
https://github.com/rust-bitcoin/rust-bitcoin/issues/462
2020-12-26 11:33:54 +01:00
0xB10C
4eca40dcc1
test: BlockHeader::validate_pow()
...
https://github.com/rust-bitcoin/rust-bitcoin/issues/462#issuecomment-683916241
2020-12-26 11:33:39 +01:00
0xB10C
d5bf5c88a3
test: BlockHeader::work()
...
https://github.com/rust-bitcoin/rust-bitcoin/issues/462#issuecomment-683916241
2020-12-26 11:33:22 +01:00
sanket1729
62fb1ec7e6
fix service flags warning
2020-12-23 09:59:42 -06:00
Andrew Poelstra
3c1117305f
Merge pull request #471 from LNP-BP/feat/psbt-keytypes
...
PSBT proprietary key system matching BIP 174
2020-12-21 15:41:06 +00:00
Steven Roose
767b14f696
Make Inventory and NetworkMessage enums exhaustive
...
Both by added an `Unknown` variant.
2020-12-21 12:04:26 +00:00
Steven Roose
944371d6a2
Clean up CommandString
...
- Add length invariant.
- Siimplify constructors.
2020-12-21 11:56:51 +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
Andrew Poelstra
a6264cfca6
Merge pull request #499 from LNP-BP/pending/psbt-global
...
New PSBT global keys
2020-12-20 21:27:57 +00:00
Dr Maxim Orlovsky
7f5c2795d6
PSBT global xpub merging algorithm reworked
2020-12-20 11:41:24 +01:00
Andrew Poelstra
99201676ae
Merge pull request #514 from stevenroose/tosocketaddrs
...
network: Implement net::ToSocketAddrs for address messages
2020-12-16 17:11:35 +00: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
Andrew Poelstra
c62cd98615
Merge pull request #516 from stevenroose/max-inv-size
...
Add message::MAX_INV_SIZE constant
2020-12-15 23:45:42 +00:00
Alekos Filini
373f355b5a
Flush unrecognized network messages from the read buffer
...
Currently whenever an unrecognized network message is received, it is never
flushed from the read buffer, meaning that unless the stream is closed and
recreated it will keep returning the same error every time `read_next()` is
called.
This commit adds the length of the message to `UnrecognizedNetworkCommand`,
so that the `StreamReader` can flush those bytes before returning the error
to the caller.
2020-12-15 19:54:21 +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
02c3d8fca5
Merge pull request #401 from dpc/sighhash_u32
...
Improve `sighash_u32` handling
2020-12-07 11:37:26 +00: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
Dawid Ciężarkiewicz
cf2c12a816
Add ability to pass `SigHashType` directly to `signature_hash`
2020-11-24 22:53:56 -08:00
Dawid Ciężarkiewicz
8773cb4a42
Document `sighash_u32` of `Transaction::signature_hash`
2020-11-24 22:50:06 -08: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
Steven Roose
f1b0f263ce
Implement PartialOrd and Ord for Inventory
2020-11-10 19:54:07 +00:00
Dr Maxim Orlovsky
fa4ecb4a6a
Making ExtendedPubKey decode aligned with ExtendedPrivKey variant
2020-11-10 09:30:33 +01:00
Steven Roose
1ec3ed3fec
Add message::MAX_INV_SIZE constant
2020-11-09 22:22:59 +00:00
Steven Roose
ab1e9cbb9e
network: Implement net::ToSocketAddrs for address messages
2020-11-09 20:13:00 +00:00
Dr Maxim Orlovsky
a802ca88ef
Using base58::check_encode_slice_to_fmt for BIP32 encodings
2020-11-08 18:29:30 +01:00
Steven Roose
4c70397a85
network: Add socket_addr method to AddrV2Message
2020-11-08 13:48:42 +00:00
Steven Roose
c7ec4f171f
network: Move AddrV2Message definition down
...
So that it is grouped together with the impls.
2020-11-08 13:43:55 +00: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
Jake Rawsthorne
921f64699c
`addrv2` and `sendaddrv2` network message
2020-10-26 21:49:06 +00:00
Jake Rawsthorne
cf8e290c99
AddrV2 structures
2020-10-26 21:46:10 +00:00
Andrew Poelstra
c16053a265
Merge pull request #446 from jrawsthorne/bip339
...
BIP339: Add wtxidrelay message and WTx inv type
2020-10-26 20:03:36 +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
aed4e02e38
Add #![deny(unused_must_use)] to avoid not checking Errs
2020-10-23 21:31:32 +01: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
545965d9e3
Change consensus::encode::serialize assert to debug_assert
...
This is just a sanity check on our own serialization code.
2020-10-23 21:28:17 +01:00
Steven Roose
ab9514983b
Add explanation to witness program version assertion
2020-10-23 21:28:16 +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
8e0b9921ae
No space- and case insensitivity for SigHashType string serialization
2020-10-14 16:46:48 +02:00
Dr Maxim Orlovsky
00c3466363
Serde implementation for PSBT
2020-10-14 16:31:24 +02:00
Dr Maxim Orlovsky
a4a7035a94
String and serde de/serialization for SigHashType
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