Commit Graph

3906 Commits

Author SHA1 Message Date
Andrew Poelstra b593778314
Merge rust-bitcoin/rust-bitcoin#2595: Release tracking PR: `base58ck v0.1.0`
c16c1be946 base58: Add changelog (Tobin C. Harding)

Pull request description:

  In preparation for release add a minimal changelog to the `base58ck` crate.

  This crate is currently unreleased and has the version number correctly set to `v0.1.0` - as of today, the crate name `base58ck` is available on crates.io.

ACKs for top commit:
  sanket1729:
    utACK c16c1be946
  apoelstra:
    ACK c16c1be946 Let's do it!

Tree-SHA512: 8c66e7823dd058257c65e40e67f4386f045cd6292f11356f80bf5e95c0fa28d573b52c57f8ba1504893e236e8124916311fa0c2af1807fdb48e3123bb3d826fb
2024-03-25 22:11:29 +00:00
Andrew Poelstra 92d8f70544
Merge rust-bitcoin/rust-bitcoin#2610: Add a validation variant to `ParseError`
a7a99e06bb Add a validation variant to `ParseError` (Tobin C. Harding)
d5c52618a9 Move NetworkValidationError within file (Tobin C. Harding)

Pull request description:

  As requested, return `ParseError` from `Address<NetworkUnchecked>::require_network`.

  - Patch 1: Preparatory refactor
  - Patch 2: Add the variant.

  Replaces #2593.

  Close: #2507

ACKs for top commit:
  sanket1729:
    ACK a7a99e06bb.
  apoelstra:
    ACK a7a99e06bb

Tree-SHA512: 08b290e5f11a5d787918a5b851f98efbeff5bd20a2838e00564f03bb242af3640da663ddc42473419255fff6f64280eaf2595706504676b3228ac81212ea7cf2
2024-03-25 21:41:25 +00:00
Tobin C. Harding a7a99e06bb
Add a validation variant to `ParseError`
`require_network` is typically called as part of parsing, often in the
same line of code. Counter to our normal errors, it makes
`require_network` more ergonomic to use if we just return a `ParseError`
variant.

Close: #2507
2024-03-25 08:45:19 +11:00
Tobin C. Harding d5c52618a9
Move NetworkValidationError within file
Done in preparation for adding the `NetworkValidationError` as a variant
of `ParseError`.

Move the `NetworkValidationError` type to beneath `ParseError`.

Code move only, no other changes.
2024-03-25 06:54:12 +11:00
Tobin C. Harding c16c1be946
base58: Add changelog
In preparation for release add a minimal changelog to the `base58ck`
crate. This crate is currently unreleased and has the version number
correctly set to `v0.1.0` - as of today, the crate name `base58ck` is
available on crates.io.
2024-03-25 06:41:38 +11:00
Andrew Poelstra c211e7be78
Merge rust-bitcoin/rust-bitcoin#2626: Replace TBD with 0.32.0
fd040f5e38 Replace TBD with 0.32.0 (Tobin C. Harding)

Pull request description:

  We are gearing up for the 0.32.0 release; replace all instances of TBD with the version number of the upcoming release.

ACKs for top commit:
  sanket1729:
    ACK fd040f5e38
  apoelstra:
    ACK fd040f5e38

Tree-SHA512: fe73fd47a794557742f618b21434cd3cc18cde0e861216716723bfcc9135accf63590e1ea60bfeda066acec7312c8b9f1bf09e7454e7161ccaba5ebe60af66fd
2024-03-24 15:15:09 +00:00
Andrew Poelstra bfd5255ae8
Merge rust-bitcoin/rust-bitcoin#2481: Improve base58 crate
af49841433 Hide base58::Error internals (Tobin C. Harding)
4f68e79da0 bitcoin: Stop using base58 errors (Tobin C. Harding)
669d5e8fc6 base58: Add InvalidCharacterError for decoding (Tobin C. Harding)
ec8609393b base58: Add error module (Tobin C. Harding)
42fabbab03 base58: Run the formatter (Tobin C. Harding)

Pull request description:

  Improve the error code in the new `base58` crate.

ACKs for top commit:
  apoelstra:
    ACK af49841433
  sanket1729:
    ACK af49841433

Tree-SHA512: c05479f02a9a58c7c98fd5987e760288562372e16cceeeb655f0a5385b4a8605945a3b6f7fcf473a7132a40f8dc90d204bc5e9e64fd2cc0bdc37dbcabb4ddc5c
2024-03-24 14:20:29 +00:00
Andrew Poelstra 26248b28ac
Merge rust-bitcoin/rust-bitcoin#2625: Put back in deprecated dust_value
c17db32df3 Pub back in deprecated dust_value (Tobin C. Harding)

Pull request description:

  When we renamed `dust_value` to `minimal_non_dust` we forgot to keep the original and deprecated it, doing so assists with the upgrade path.

  Put back in deprecated `dust_value`, linking to the rename.

  Renamed in #2255, found while testing upgrade of downstream software.

ACKs for top commit:
  tcharding:
    > ACK [c17db32](c17db32df3) I _think_ this matches the behavior of the old version
  apoelstra:
    ACK c17db32df3 I *think* this matches the behavior of the old version
  sanket1729:
    ACK c17db32df3

Tree-SHA512: 28e1bd2e1a0fd13c78c70ad2667b72b3bf649c293201b79c86c00f09d0126389ebaeb430b8dd32aeeec3d60cbd8761ae949f5784a5ea7756b1b9ae77ec96ce61
2024-03-24 13:56:34 +00:00
Andrew Poelstra 1656e1a09a
Merge rust-bitcoin/rust-bitcoin#2619: Call is_witness_program from witness_version
dec05b63e9 Refactor witness_version and is_witness_program (Tobin C. Harding)
dac552b436 Add unit tests for shortest/longest witness program (Tobin C. Harding)

Pull request description:

  Refactor `witness_version` and `is_witness_program`.

  - Patch 2 adds a couple of preparatory unit tests.
  - Patch 2 does the refactor

  Fix: #2618

ACKs for top commit:
  apoelstra:
    ACK dec05b63e9
  sanket1729:
    ACK dec05b63e9

Tree-SHA512: 3db0a1d8175cbb2fd18f3254854d02db3ad7efa2620b12f08d9727ef6bb5854f0a015917e57023cd2196a36d13276e80536a0e96318c44a1173da4f6793ca370
2024-03-22 23:52:42 +00:00
Andrew Poelstra 3851441265
Merge rust-bitcoin/rust-bitcoin#2549: improve relative locktime API
04715e3e60 absolute: make is_* methods uniform with the ones from relative (Andrew Poelstra)
878b865f85 relative locktime: introduce is_* methods to check units (Andrew Poelstra)
c2f87c7ab3 relative locktime: add is_implied_by method for sequences (Andrew Poelstra)
319e102fed relative locktime: use From/TryFrom to convert between relative locktimes and Sequence (Andrew Poelstra)
0ed26915f6 relative locktime: add conversions to/from sequence (Andrew Poelstra)
5c8fb5c11b relative locktime: add consensus encode/decode functions (Andrew Poelstra)
ac968e02b6 relative locktime: constify a bunch of constructors (Andrew Poelstra)
f27e675e1e relative locktime: add "obvious" constructors (Andrew Poelstra)
f02b1dac5b relative locktime: copy comments and PartialOrd impl from absolute locktimes (Andrew Poelstra)
2ff5085e70 locktimes: run cargo fmt (Andrew Poelstra)

Pull request description:

  While implementing https://github.com/rust-bitcoin/rust-miniscript/pull/654 I ran into a number of limitations of the `relative::LockTime` API. This fixes these by

  * Copying a ton of functions from `absolute::LockTime` to `relative::LockTime`, adjusting comments and functionality accordingly.
  * Adding conversion functions to/from `Sequence` numbers, as well as a method to check whether a locktime is satisfied by a given sequence number.

  Fixes #2547
  Fixes #2545
  Fixes #2540

ACKs for top commit:
  tcharding:
    ACK 04715e3e60
  sanket1729:
    ACK 04715e3e60

Tree-SHA512: 70740eaa3a83dc1e7312b99e907ccdcef4eeb6191ae881d81712707ad6fb949c4e28183ab6f9258c6cde1ef8fdd5dc6476439e705a9e02a939b7832430a608d4
2024-03-22 21:32:59 +00:00
Tobin C. Harding 42d02fbd66
Merge Refactor and One ACK carve outs
The "One ACK carve-out" has 3 rules and then there is a separate
"Refactor carve-out" that covers things that are not only refactoring -
this makes it hard to reference the carve-outs in github because its a
bit confusing.

Merge the carve-outs into a single "one ACK carve-out" with multiple
rules. Use rule 0 for the original refactor carve-out stuff because it
makes the diff smaller and all good lists start with 0.

Also remove mention of the refactor carve-out from rule 3.
2024-03-23 07:20:49 +11:00
Tobin C. Harding ebf5b670d4
Update test script mention
In the One ACK carve out just say "test scripts" instead of `test.sh`
because we re-named the test scripts recently.
2024-03-23 07:12:06 +11:00
Tobin C. Harding fd040f5e38
Replace TBD with 0.32.0
We are gearing up for the 0.32.0 release; replace all instances of TBD
with the version number of the upcoming release.
2024-03-23 05:36:52 +11:00
Tobin C. Harding c17db32df3
Pub back in deprecated dust_value
When we renamed `dust_value` to `minimal_non_dust` we forgot to keep the
original and deprecated it, doing so assists with the upgrade path.

Pub back in deprecated `dust_value`, linking to the rename.
2024-03-23 05:32:15 +11:00
Andrew Poelstra 08ff359dc7
Merge rust-bitcoin/rust-bitcoin#2578: Document how to write commits
8bd0394b0a Document how to write commits (Tobin C. Harding)

Pull request description:

  Reviewers often find themselves linking to blog posts to encourage newer devs to improve their commit logs, we can save everyones time by putting the links in the contributing docs, then we can just point devs there.

ACKs for top commit:
  apoelstra:
    ACK 8bd0394b0a

Tree-SHA512: b2713c2882c3153152091bd2a72a473e151cf1e3e93288ae17b773c9f2944805a78c991437c9951d9fe5478c76a31d5c0f2ac0212bda6cbca531681a7b41f988
2024-03-22 14:18:07 +00:00
Andrew Poelstra 04715e3e60
absolute: make is_* methods uniform with the ones from relative 2024-03-21 22:10:17 +00:00
Andrew Poelstra 878b865f85
relative locktime: introduce is_* methods to check units
Copy these from absolute::LockTime. While we are at it, make the
functions in absolute::LockTime const.
2024-03-21 22:10:17 +00:00
Andrew Poelstra c2f87c7ab3
relative locktime: add is_implied_by method for sequences
This gives a way to determine whether a CSV will pass, given a sequence
number, in a type-safe way where you can't get the two things backward.
2024-03-21 22:10:17 +00:00
Andrew Poelstra 319e102fed
relative locktime: use From/TryFrom to convert between relative locktimes and Sequence 2024-03-21 22:10:17 +00:00
Andrew Poelstra 0ed26915f6
relative locktime: add conversions to/from sequence 2024-03-21 22:10:17 +00:00
Andrew Poelstra 5c8fb5c11b
relative locktime: add consensus encode/decode functions 2024-03-21 22:10:13 +00:00
Andrew Poelstra ac968e02b6
relative locktime: constify a bunch of constructors 2024-03-21 22:07:29 +00:00
Andrew Poelstra f27e675e1e
relative locktime: add "obvious" constructors
Adds constructors to allow directly creating locktimes from time or
block counts; adds a flooring constructor to Time to match the ceiling
one; adds an explicit constructor to Height since the From<u16> was not
very discoverable.
2024-03-21 22:07:25 +00:00
Andrew Poelstra f02b1dac5b
relative locktime: copy comments and PartialOrd impl from absolute locktimes 2024-03-21 22:07:25 +00:00
Andrew Poelstra 2ff5085e70
locktimes: run cargo fmt 2024-03-21 22:07:25 +00:00
Tobin C. Harding dec05b63e9
Refactor witness_version and is_witness_program
These two functions are related. We cannot, by definition, get the
witness version from a script that is not a witness program but
currently the code is not linking these two things.

Refactor by doing:

- Move the check of the witness program bip rules to `witness_version`
- Call `witness_version().is_some()` in the predicate

Improve the docs while we are at it to include the bip text in the
rustdoc. Note I didn't bother referencing the segwit bip number, this
bip text is pretty well known.
2024-03-22 07:07:07 +11:00
Tobin C. Harding dac552b436
Add unit tests for shortest/longest witness program
Add two unit tests that verify we can correctly determine if a
shortest allowed and longest allowed script is a witness program.

Done in preparation for patching the `witness_version` function.
2024-03-22 07:03:30 +11:00
Tobin C. Harding 0ca5a43ce5
hashes: Bump version to v0.14.0
In preparation for release add a changlelog entry and bump the version.

I'm not 100% sure that this release is API breaking, dependencies
definitely changed. The rest might be only additives but I didn't bother
looking exactly because I think its better to bump the minor version and
err on the side of caution.

Note the hashes 0.13.0 dependency stays in the dependency graph because
of secp, we can update secp after releasing `hashes` then update the
secp dependency in `rust-bitcoin` thereby removing the `hashes v0.13.0`
dependency - phew.
2024-03-22 06:04:40 +11:00
Andrew Poelstra 7c910d5612
Merge rust-bitcoin/rust-bitcoin#2622: fuzz: Use path in manifest instead of version
d38cb8af9e fuzz: Use path in manifest instead of version (Tobin C. Harding)

Pull request description:

  Using `path` instead of `version` makes the `fuzz` crate easier to maintain because we don't have to update the version number to do releases.

ACKs for top commit:
  apoelstra:
    ACK d38cb8af9e neat, I did not know you could do this

Tree-SHA512: dd3d4526e6599c0752aef07393238b381b166d0d5b436a4babe967c6b282aa47079583b36ecea7a17279b1de135591950c07c9d6f2ba8e50d349bc62ca77f5c6
2024-03-21 14:55:12 +00:00
Tobin C. Harding d38cb8af9e
fuzz: Use path in manifest instead of version
Using `path` instead of `version` makes the `fuzz` crate easier to
maintain because we don't have to update the version number to do
releases.
2024-03-21 16:20:03 +11:00
Andrew Poelstra 2b9568158b
Merge rust-bitcoin/rust-bitcoin#2617: Revert #2525 (filter CI)
50e772fe79 Revert "ci: introduce `classify-pr.sh` script which determines whether a PR should have CI run" (Andrew Poelstra)
ae381fcc01 Revert "ci: gate CI workflow on source being changed" (Andrew Poelstra)
495d7e8acd Revert "ci: gate fuzztesting on whether source code changed" (Andrew Poelstra)
ec3e4e8801 Revert "ci: gate coverage analysis on whether source code changed" (Andrew Poelstra)

Pull request description:

  This PR did not work on the "master" CI runs and I really don't care enough to figure it out (or even how to test it). Just revert it.

ACKs for top commit:
  tcharding:
    ACK 50e772fe79

Tree-SHA512: c56b77dab93e9917b2420f5b7f178bfa05500f8329852296102d72df33c5de87d45ee79f235a4ce30e629bc79b2b290a2fcb97d7808c406bfe07c9fe7e1cc997
2024-03-20 22:13:33 +00:00
Tobin C. Harding af49841433
Hide base58::Error internals
As is convention here in `rust-bitcoin`, hide the `base58::Error`
internals by adding struct error types.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 4f68e79da0
bitcoin: Stop using base58 errors
We are currently using the `base58::Error` type to create errors in
`bitcoin`, these are bitcoin errors not `base58` errors.

Note that we add what looks like duplicate
`InvalidBase58PayloadLengthError` types but they are different because
of the expected length. This could have been a field but I elected not
to do so for two reasons:

1. We will need to do so anyways if we crate smash more
2. The `crypto::key` one can have one of two values 33 or 34.

With this applied we can remove the now unused error variants from
`base58::Error`.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 669d5e8fc6
base58: Add InvalidCharacterError for decoding
The `base58::decode` function can only return a single error type, add a
`InvalidCharacterError` struct (leaf error) to use as the return type.
2024-03-21 06:22:51 +11:00
Tobin C. Harding ec8609393b
base58: Add error module
In preparation for improving the `base58` error types crate an `error`
module and move the single current error type there. Make the module
public and reexport the type.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 42fabbab03
base58: Run the formatter 2024-03-21 06:22:49 +11:00
Andrew Poelstra 6ff850539a
Merge rust-bitcoin/rust-bitcoin#2503: base58: Re-name crate to base58ck
6b09857f55 base58: Re-name crate to base58ck (Tobin C. Harding)

Pull request description:

  The current name `base58check` is taken, as is `base58`. Use `base58ck` instead.

  Add a brief section to the readme about the crate naming.

ACKs for top commit:
  apoelstra:
    ACK 6b09857f55
  sanket1729:
    ACK 6b09857f55

Tree-SHA512: 86ee08105906a6f3403dc2602e827b0d46226798ecdedb420ad3ac4b657d6a00e25eabcdfbdb9f8e89bdc3a38e608189f1e073e65593f89a2ad853e8ff027f69
2024-03-20 18:56:22 +00:00
Andrew Poelstra 4d90e0b2c4
Merge rust-bitcoin/rust-bitcoin#2528: hash_types: add unit tests for display of all hash types in the library
b816c0bb01 hash_types: add unit tests for display of all hash types in the library (Andrew Poelstra)

Pull request description:

  This can be checked against the 0.29.x branch, and against the commit prior to #1659 (40c246743b^) and you will see that it is consistent EXCEPT:

  * In rust-bitcoin 0.29.x we did not have multiple sighash types, only `Sighash`; we now have `LegacySighash`, `SegwitV0Sighash`, and `TapSighash`.
  * In #1565 we deliberately changed the display direction of the sighashes, to match BIP 143.

  Fixes #2495.

ACKs for top commit:
  tcharding:
    That's a win. ACK b816c0bb01

Tree-SHA512: 5b44f40165699910ea9ba945657cd1f960cf00a0b4dfa44c513feb3b74cda33ed80d3551042c15b85d6e57c30a54242db202eefd9ec8c8b6e1498b5578e52800
2024-03-20 16:33:58 +00:00
Andrew Poelstra 50e772fe79
Revert "ci: introduce `classify-pr.sh` script which determines whether a PR should have CI run"
This reverts commit 9aca8a18c7.
2024-03-20 14:08:17 +00:00
Andrew Poelstra ae381fcc01
Revert "ci: gate CI workflow on source being changed"
This reverts commit 09f7fc3cff.
2024-03-20 14:08:16 +00:00
Andrew Poelstra 495d7e8acd
Revert "ci: gate fuzztesting on whether source code changed"
This reverts commit 2203c02347.
2024-03-20 14:08:15 +00:00
Andrew Poelstra ec3e4e8801
Revert "ci: gate coverage analysis on whether source code changed"
This reverts commit 32f9b1a231.
2024-03-20 14:08:14 +00:00
Andrew Poelstra f495bd9681
Merge rust-bitcoin/rust-bitcoin#2525: ci: skip CI for things that modify only markdown files
32f9b1a231 ci: gate coverage analysis on whether source code changed (Andrew Poelstra)
2203c02347 ci: gate fuzztesting on whether source code changed (Andrew Poelstra)
09f7fc3cff ci: gate CI workflow on source being changed (Andrew Poelstra)
9aca8a18c7 ci: introduce `classify-pr.sh` script which determines whether a PR should have CI run (Andrew Poelstra)

Pull request description:

  Fixes #2523

ACKs for top commit:
  tcharding:
    ACK 32f9b1a231

Tree-SHA512: 7d53365bdf4e8ae5480221e43b4c515d4b16048ec1a00cb62ab65b2d2b91a37f8945c39b619a82bfe4ca74f3508176d9879481b908bb8d3fe8d214b173d3bf18
2024-03-20 14:01:32 +00:00
Andrew Poelstra 59a58fdca8
Merge rust-bitcoin/rust-bitcoin#2518: Re-export `address::error::P2shError` from `address` module
0d517dcfdd Re-export P2shError (Tobin C. Harding)
646ee1a837 Put re-exports in alphabetic order (Tobin C. Harding)

Pull request description:

  As with the rest of the errors in `address::error` that are returned by a pubic function from the `address` module.

  Note please, this PR just makes the `address/mod.rs` file uniform, debating the merit of the re-exports is out of scope.

ACKs for top commit:
  apoelstra:
    ACK 0d517dcfdd

Tree-SHA512: a65ebe6de62b83c6d3723c7c97a0953ddb8da51964ef54e69865855502ae5fa51b2b49c6fd408c452414b56518f4c7ab763faca925e8d81f0fe806af1df92aa2
2024-03-20 13:43:52 +00:00
Andrew Poelstra 51bb6a2d69
Merge rust-bitcoin/rust-bitcoin#2582: fix: Manually implement serde traits
911f8cbd6a fix: Manually implement serde traits (Tobin C. Harding)

Pull request description:

  Currently we are deriving the serde traits for the `absolute::{Height, Time}` types, this is incorrect because we maintain an invariant on the inner `u32` of both types that it is above or below the threshold.

  Manually implement the serde traits and pass the deserialized `u32` to `from_consensus` to maintain the invariant.

  Close: #2559

ACKs for top commit:
  apoelstra:
    ACK 911f8cbd6a
  sanket1729:
    ACK 911f8cbd6a.

Tree-SHA512: 28f9f3e23b2016e00216e5e94f35e22a5bfa6b29e1dd30fa3351575eafc2e47dbd98aa8e51631de2f09eec8d881b0e5e79231185c7a293c1ba0170a90fbbd19d
2024-03-20 13:28:59 +00:00
Tobin C. Harding 911f8cbd6a
fix: Manually implement serde traits
Currently we are deriving the serde traits for the `absolute::{Height,
Time}` types, this is incorrect because we maintain an invariant on
the inner `u32` of both types that it is above or below the threshold.

Manually implement the serde traits and pass the deserialized `u32` to
`from_consensus` to maintain the invariant.

Close: #2559
2024-03-20 11:33:14 +11:00
Andrew Poelstra 6389d3f7fc
Merge rust-bitcoin/rust-bitcoin#2577: Fix cargo cult programming
290e4418e6 units: Fix cargo cult programming (Tobin C. Harding)

Pull request description:

  When creating the ParseIntError in `hex_u32` I (tobin) just cargo cult programmed the generic stuff without thinking.

  - The `is_signed` field is used to denote whether we were attempting to parse a signed or unsigned integer, it should be `false`.
  - The `bits` field should be directly set to 32.

ACKs for top commit:
  apoelstra:
    ACK 290e4418e6
  sanket1729:
    ACK 290e4418e6

Tree-SHA512: 7dfd9f0cd98eff1c2b27a92dac5c4e2fe0fa4ae724528ef741fe43d8d923e2d31cbdcd4e540ecfba1b953860dc2b728a958e756e2d2012d9a9e715c0ca3c5068
2024-03-19 15:50:33 +00:00
Andrew Poelstra 002590be70
Merge rust-bitcoin/rust-bitcoin#2607: merkle_block: add resource limit check during deserialization
f1dcfab293 merkle_block: add resource limit check during deserialization (Andrew Poelstra)

Pull request description:

  Fixes #2606

ACKs for top commit:
  tcharding:
    ACK f1dcfab293
  sanket1729:
    ACK f1dcfab293

Tree-SHA512: f0ab0f7a7bd7f38741149263a2c321b0ec9f09d299be96c5174c4e21edd383fc2824574a790331769dee1f06e3ad1dd53601921eb82038e08235b797d68a37fd
2024-03-19 15:31:29 +00:00
Tobin C. Harding 290e4418e6
units: Fix cargo cult programming
When creating the ParseIntError in `hex_u32` I (Tobin) just cargo cult
programmed the generic stuff without thinking.

- The `is_signed` field is used to denote whether we were attempting to
parse a signed or unsigned integer, it should be `false`.
- The `bits` field should be directly set to 32.
2024-03-19 09:59:11 +11:00
Tobin C. Harding 6b09857f55
base58: Re-name crate to base58ck
The current name `base58check` is taken, as is `base58`. Use `base58ck`
instead.

Add a brief section to the readme about the crate naming.
2024-03-19 09:00:46 +11:00