Commit Graph

4231 Commits

Author SHA1 Message Date
Tobin C. Harding 9f01871c11
api: Run just check-api 2024-06-14 14:19:07 +10:00
Tobin C. Harding 7929b51640
Pass keys by value
We should pass `Copy` types by value not by reference. Pass the key
types by value.
2024-06-14 14:16:28 +10:00
Tobin C. Harding c81e330e48
Link to std::error::Error
In #2521 I removed the link from `std::error::Error` with the claim that
it broke no-std builds. However there are a ton of other places where we
link to `std::` types.

I have no idea where the breakage was, I assume it existed and I was
sane at the time, CI on this patch will tell us.

Close: #2571
2024-06-14 14:00:58 +10:00
Tobin C. Harding 1f58476cb4
Run schemars test from extra_tests
We have a mechanism to run additional custom tests by way of the
`extra_tests.sh` script in each crate.

Remove the CI job and run the schemars test using `extra_tests.sh`. This
patch changes the test coverage because currently the schemars test is
only run with a stable toolchain but with this patch applied it runs
with stable, MSRV, and nightly.

Fix: #2787
2024-06-14 13:44:18 +10:00
Tobin C. Harding efdcadf2fd
Merge rust-bitcoin/rust-bitcoin#2862: Automated daily update to rustc (to nightly-2024-06-12)
024d1fa53b Automated update to Github CI to rustc nightly-2024-06-12 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 024d1fa53b

Tree-SHA512: e075c3aca81ab3cddbac470f17d48acf39483e664341894203f042a01cec12534efd013c070c6985c864687ef8575f2df31d2eb8af33dea952bb6676f667640a
2024-06-14 13:32:25 +10:00
Tobin C. Harding 18b2788a5a
api: Run just check-api 2024-06-14 10:51:01 +10:00
Tobin C. Harding 6b7d02e5ae
Add inherent functions to hashes
Currently we have a trait `Hash` that is required for `Hmac`, `Hkdf`,
and other use cases. However, it is unegonomic for users who just want
to do a simple hash to have to import the trait.

Add inherent functions to all hash types including those created with
the new wrapper type macros.

This patch introduces some duplicate code but we are trying to make
progress in the hashes API re-write. We can come back and de-dublicate
later.

Includes making `to_byte_array`,`from_byte_array`, `as_byte_array`, and
`all_zeros` const where easily possible.
2024-06-14 10:17:00 +10:00
Andrew Poelstra 59d06f7073
Merge rust-bitcoin/rust-bitcoin#2859: Moved private doctest to unit test
8d256b4e79 Moved doctest to unit test (Jamil Lambert, PhD)

Pull request description:

  Moved the doctest from the private module to a unit test to fix: #2840

ACKs for top commit:
  apoelstra:
    ACK 8d256b4e79
  tcharding:
    ACK 8d256b4e79

Tree-SHA512: 233961288579381cb5c51235331c78c9980046f0317a2062cb108a2e604adde322e2dd834e724d1fe05f54f92721fe6c9f5344dcf930f99aa3756a698ddf9732
2024-06-13 13:20:32 +00:00
Update Nightly Rustc Bot 024d1fa53b Automated update to Github CI to rustc nightly-2024-06-12 2024-06-13 01:23:39 +00:00
Jamil Lambert, PhD 8d256b4e79 Moved doctest to unit test
Moved the doctest from the private module to a unit test, since it does not appear in doc.rs.
2024-06-12 16:00:28 +01:00
Andrew Poelstra c4f2f2454f
Merge rust-bitcoin/rust-bitcoin#2816: make difficulty_float general to all network
fcf27a62a2 update api (Divyansh Gupta)
531aba0cf1 make `difficulty_float` general to all network (Divyansh Gupta)

Pull request description:

  Fix #2783

ACKs for top commit:
  tcharding:
    ACK fcf27a62a2
  apoelstra:
    ACK fcf27a62a2

Tree-SHA512: aec9648b057677b89f4f397e1fa703ed6496436bd6e1e8052d5b7f52ef52c95b286babd425d97fe7d4f903cd0a3d68ae589d8fb255fc68f423714918cd485873
2024-06-12 13:34:44 +00:00
Divyansh Gupta fcf27a62a2 update api 2024-06-12 09:23:53 +05:30
Divyansh Gupta 531aba0cf1 make `difficulty_float` general to all network 2024-06-12 09:22:40 +05:30
Andrew Poelstra 76b0060c4d
Merge rust-bitcoin/rust-bitcoin#2856: bitcoin: Remove "std" feature from examples
091d614aad bitcoin: Remove "std" feature from examples (Tobin C. Harding)

Pull request description:

  The "rand-std" feature enables "std" but we use it in examples still. FTR I added this a while ago thinking the explicitness was clearer but in hindsight I think that was wrong and that it makes usage of our features _less_ clear.

  No logic changes.

  (Pulled out of #2756.)

ACKs for top commit:
  storopoli:
    ACK 091d614aad
  apoelstra:
    ACK 091d614aad

Tree-SHA512: d72eec37e3a434a1f850cb4257529fc18540cb5075bc7d3bd494cba59b08404c6c86223361a3c3a3de8d50a1168b656ff1123d28f7d2dcdf05c404caff716b1a
2024-06-12 03:52:08 +00:00
Andrew Poelstra cf870bbd7b
Merge rust-bitcoin/rust-bitcoin#2833: Update bitcoinconsensus version to 0.106.0+26
2db88a62fd Update bitcoinconsensus version (Jamil Lambert, PhD)

Pull request description:

  Updated bitcoinconsensus version to 0.106.0+26.0 in bitcoin/Cargo.toml

  The new version supports taproot and has a new parameter for `spent_outputs` in the `verify()` and `verify_with_flags()` functions.

  The validation module was changed to keep the existing functionality by adding `None` as the `spent_outputs` and the flag `VERIFY_ALL_PRE_TAPROOT`.

  This method does not add taproot features to the verify functions.

ACKs for top commit:
  tcharding:
    ACK 2db88a62fd
  apoelstra:
    ACK 2db88a62fd agreed, this is a good step forward

Tree-SHA512: b6cef395e065cfe859a7896ee2deb2f2d255051566751c10d06092064f6523338ca912aad81b789d6ca94e6f6164f2eef874ad6086c6ebe1384ce520d6eba366
2024-06-11 21:57:36 +00:00
Andrew Poelstra cd768303dc
Merge rust-bitcoin/rust-bitcoin#2857: Remove repetition from sha256t_hash_newtype macro
8aa893ebd0 Remove repetition from sha256t_hash_newtype macro (Tobin C. Harding)

Pull request description:

  The `sha256t_hash_newtype` macro is hard to reason about because we allow repetition so which tag goes with which type is slightly obscure.

  Remove repetition and call the macro three times.

  Internal change in `bitcoin`, API change in `hashes`.

  Fix #2811

ACKs for top commit:
  apoelstra:
    ACK 8aa893ebd0 nice, small diff

Tree-SHA512: b38e7c307ac7288b4a5c1c3170ad6aa54c62bd3198922ec8bb091867b230bb9149f7dc996766fc8fa20a1af18b318c475b3e83e2689d322b7f4af0d5cb588e50
2024-06-11 19:46:52 +00:00
Andrew Poelstra 138778c539
Merge rust-bitcoin/rust-bitcoin#2851: hashes: Move non-trait functions
ce1db3ea26 hashes: Move non-trait functions (Tobin C. Harding)

Pull request description:

  The `hash_trait_impls` macro currently adds an impl block for `Hash` - this is not what the docs say since and `impl Hash` block is nothing to do with traits.

  Move the impl block and add a duplicate of the functions to the `sha256t::Hash` type.

  This is a refactor, no API or logic changes. Note that wrapper types currently do net get these functions - that will be discussed/implemented separately.

ACKs for top commit:
  apoelstra:
    ACK ce1db3ea26 Ok, this one is easy :)

Tree-SHA512: c25bc2bcfdae8130bbcb9d212701504e15a8429630ae4ce924dcf1c54bb10e122aa67d1abed8bb338e4844de715816dc49ca4de7bf16033f293817c398717756
2024-06-11 18:32:13 +00:00
Jamil Lambert, PhD 2db88a62fd Update bitcoinconsensus version
Updated bitcoinconsensus version to 0.106.0+26.0.

The new version supports taproot and has a new parameter for spent outputs in the `verify()` and `verify_with_flags()` functions.

The validation module was changed to keep the existing functionality by adding `None` as the `spent_outputs` and the flag `VERIFY_ALL_PRE_TAPROOT`.
2024-06-11 14:31:32 +01:00
Andrew Poelstra aedb09745a
Merge rust-bitcoin/rust-bitcoin#2839: Add API for extracting the inner payload of `RawNetworkMessage`
ce585dc529 api: Run just check-api (Liu-Cheng Xu)
61565957ad Add API for extracting the inner payload of RawNetworkMessage (Liu-Cheng Xu)

Pull request description:

  I'd like to take out the `payload` of `RawNetworkMessage` and then send it to the actual network message processor, but find there is no way to do it. This commit adds such an API to expose all the inner parts (UPD: so that I don't have to do an unnecessary clone to obtain the owned value of `payload`).

ACKs for top commit:
  apoelstra:
    ACK ce585dc529
  tcharding:
    ACK ce585dc529

Tree-SHA512: 89c5f1361a8c2d0ecf928325e9a37b26d39cf32c3a023b78742555a5a1e59e1579522e942ff6f48b07b2d3b81b48c5e8182fa6e88b57fc9c33ce13e313ba2982
2024-06-11 04:03:21 +00:00
Tobin C. Harding 8aa893ebd0
Remove repetition from sha256t_hash_newtype macro
The `sha256t_hash_newtype` macro is hard to reason about because we
allow repetition so which tag goes with which type is slightly obscure.

Remove repetition and call the macro three times.

Internal change in `bitcoin`, API change in `hashes`.
2024-06-11 13:59:55 +10:00
Tobin C. Harding 091d614aad
bitcoin: Remove "std" feature from examples
The "rand-std" feature enables "std" but we use it in examples still.
FTR I added this a while ago thinking the explicitness was clearer but
in hindsight I think that was wrong and that it makes usage of our
features _less_ clear.

No logic changes.
2024-06-11 13:51:00 +10:00
Tobin C. Harding ce1db3ea26
hashes: Move non-trait functions
The `hash_trait_impls` macro currently adds an impl block for `Hash` -
this is not what the docs say since and `impl Hash` block is nothing
to do with traits.

Move the impl block and add a duplicate of the functions to the
`sha256t::Hash` type.

This is a refactor, no API or logic changes. Note that wrapper types
currently do net get these functions - that will be
discussed/implemented separately.
2024-06-11 13:03:09 +10:00
Tobin C. Harding 1fdcf79c3a
Merge rust-bitcoin/rust-bitcoin#2838: Automated daily update to rustc (to nightly-2024-06-09)
d89b7bd770 Automated update to Github CI to rustc nightly-2024-06-09 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK d89b7bd770

Tree-SHA512: 96f2fd63c511683f23d345b6bfc655614003f59e99624653247d73b541dda5f62cf44fc4c4737e0a8aaf1cbfcc8d7374f0cdd23ab268944029f0cc2e39fa16fa
2024-06-11 13:02:41 +10:00
Andrew Poelstra f934132b3b
Merge rust-bitcoin/rust-bitcoin#2846: generate Network <-> Magic From and TryFrom with a macro
76826313a1 generate Network <-> Magic From and TryFrom with a macro (Antoni Spaanderman)

Pull request description:

  Removes possible errors when a network is added to the enum (expressed with the comment `// Note: new network entries must explicitly be matched in 'try_from' below.`)

ACKs for top commit:
  Kixunil:
    ACK 76826313a1
  apoelstra:
    ACK 76826313a1

Tree-SHA512: 37aaf4b9021204c24e3dc405e666f3dea8c4f8e478b26892dd962a49c988904ba02c3dee7cec1ad78d4e4bb9ba9565ec4574d0e169dd215d26b010f1c4dd3d0b
2024-06-10 13:59:52 +00:00
Andrew Poelstra 4543309518
Merge rust-bitcoin/rust-bitcoin#2845: fix ServiceFlags::remove
0949be931a fix ServiceFlags::remove (Antoni Spaanderman)

Pull request description:

  Contrary to the documentation and the method name, this function does an XOR operation, if there are no flags in `self`, flags from `other` are added.

  What should happen to the core::ops::BitXor{,Assign} implementations? I did not touch them because it would break current API usage and would require a minor version bump (on 0.x.y versions).

ACKs for top commit:
  Kixunil:
    ACK 0949be931a
  apoelstra:
    ACK 0949be931a looks good. I think it is fine to retain a BitXor impl on a flag type, even if it is questionably useful

Tree-SHA512: d73853e5fe5e3776ef5cfb54c1ae2f9151c17c51861759b096eae339d4c9a544a9a32f5cc23e76f79827a40425a8a0823e2b989ed9ab98b8373d2b8d94418e8e
2024-06-10 01:50:58 +00:00
Update Nightly Rustc Bot d89b7bd770 Automated update to Github CI to rustc nightly-2024-06-09 2024-06-10 01:25:45 +00:00
Andrew Poelstra 0d72db7727
Merge rust-bitcoin/rust-bitcoin#2847: Automated nightly rustfmt (2024-06-09)
8e9be3beed 2024-06-09 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  apoelstra:
    ACK 8e9be3beed

Tree-SHA512: 108984e580a61d979ce77e6a366e6dfcfd704cc420a68d25db211974321842342d61c0f63bfa259f56d63d9a69af49099b0157db6ba3f926e1d6543f5a839d26
2024-06-09 22:47:30 +00:00
Fmt Bot 8e9be3beed 2024-06-09 automated rustfmt nightly 2024-06-09 01:09:23 +00:00
Antoni Spaanderman 76826313a1
generate Network <-> Magic From and TryFrom with a macro 2024-06-09 00:23:28 +02:00
Antoni Spaanderman 0949be931a
fix ServiceFlags::remove 2024-06-09 00:09:00 +02:00
Andrew Poelstra f260b097f4
Merge rust-bitcoin/rust-bitcoin#2830: Fix Rustdocs warnings in `just check-api`
a09c3c5225 Check API: remove false positives on rustdoc (Jose Storopoli)

Pull request description:

  Fixes the rustdocs build warnings.
  This PR is composed by two commits:

  - Updates `contrib/check-for-api-changes.sh` to ignore
    `rustdoc::broken_intra_doc_links` due to the features being turned on and off
    (see rationale below); and
  - Adds a `just doc` quick check that will check for all missing rustdoc broken links
    to counterbalance the allow flag above.

  As jyap808 has pointed out in #2800,
  we might not have a simple fix for these rustdoc build warnings inside the `just check-api`.
  This can be mitigated by adding a simple allow flag to `RUSTDOCFLAGS` in `contrib/check-for-api-changes.sh`.

  > Took a quick look at this. Not sure if there's anything obvious to fix.
  >
  > A few warnings mentioning [`ordered::ArbitraryOrd`] which is only enabled when the "--features ordered" flag is used. No warning when the flag is enabled. Generated docs look OK.
  >
  > jyap808 in #2800

  Closes #2800.

  I don't know if this is the intended solution, or if we want to add more CI checks for the docs.
  Note that these docs checks are already covered in `rust-bitcoin/rust-bitcoin-maintainer-tools`: 3494ceec52/ci/run_task.sh (L275-L278)

  Any feedback will be appreciated.

ACKs for top commit:
  apoelstra:
    ACK a09c3c5225
  tcharding:
    ACK a09c3c5225

Tree-SHA512: d8a4a14a220d907a072fb283075c168e8264d01e73bf6b600f9c562337836ff6ea47cd0ab326bebd997522d5fdf32ae5a9b82c6951741595ec41c13ad49bc2ce
2024-06-07 16:51:58 +00:00
Andrew Poelstra 8dbc990448
Merge rust-bitcoin/rust-bitcoin#2832: Standardized rustdoc style
5e7a638b4d fix crypto rustdocs (Jamil Lambert, PhD)
bac30d3e6e fix rustdocs in bip152 (Jamil Lambert, PhD)
4a9f74b55c fix missing fullstops in bitcoin rustdoc (Jamil Lambert, PhD)

Pull request description:

  Updated some of the rustdocs to make the style consistent.  There is still more to do which I can work on if it is useful?

ACKs for top commit:
  tcharding:
    ACK 5e7a638b4d
  apoelstra:
    ACK 5e7a638b4d

Tree-SHA512: 3813900d4f15e95a290286a4d9efd8010625150a09dd4f601ab6279e3e0bd5cfa8b2f1628543d7279b4b26f1e7e85d10338d3401a7b6e9794684d02fa0e8fda1
2024-06-07 16:15:36 +00:00
Andrew Poelstra 7a93f78e3f
Merge rust-bitcoin/rust-bitcoin#2841: fuzz: add more coverage for `deserialize_psbt`
55cbae9c2f fuzz: add more coverage for `deserialize_psbt` (Bruno Garcia)

Pull request description:

  This PR adds more coverage for `deserialize_psbt` harness. It uses the `data` to create more than one psbt and then combine them.

ACKs for top commit:
  apoelstra:
    ACK 55cbae9c2f yeah, I like this

Tree-SHA512: 568899be8a82595c07e7b47c3011c093ce4ce49962e14781ea0c2eb9608fbba9920bbc81a296ec49d6ca124b813715bc0b8eb0cf887d44bbf8190f9a10c18845
2024-06-07 15:14:07 +00:00
Liu-Cheng Xu ce585dc529 api: Run just check-api 2024-06-07 08:59:38 +08:00
Liu-Cheng Xu 61565957ad Add API for extracting the inner payload of RawNetworkMessage
I'd like to take out the `payload` of RawNetworkMessage and
then send it to the actual network message processor, but
finds there is no way to do it. This commit adds such an API
to expose the owned value of inner `payload`.
2024-06-07 08:59:31 +08:00
Bruno Garcia 55cbae9c2f fuzz: add more coverage for `deserialize_psbt` 2024-06-06 13:49:32 -03:00
Jamil Lambert, PhD 5e7a638b4d fix crypto rustdocs
Fixed the rustdocs for some of the functions to be in third person, and small gramatical changes.
2024-06-06 16:54:02 +01:00
Jamil Lambert, PhD bac30d3e6e fix rustdocs in bip152
Added backticks on links and changed to third person on function rustdocs
2024-06-06 16:37:12 +01:00
Jamil Lambert, PhD 4a9f74b55c fix missing fullstops in bitcoin rustdoc
Added missing fullstops to the rustdoc titles for everything on the main page of the bitcoin crate
2024-06-06 16:37:12 +01:00
Andrew Poelstra 160f6de4b6
Merge rust-bitcoin/rust-bitcoin#2747: bitcoin: Add PSBT multiple inputs examples
34a5da5f16 bitcoin: Add Taproot PSBT multiple inputs examples (Jose Storopoli)
b8dc0617c9 bitcoin: Add ECDSA PSBT multiple inputs examples (Jose Storopoli)

Pull request description:

  Adds examples on how to create,
  update, sign, and finalize PSBTs version 0
  that deals with multiple inputs.

  Examples are SegWit V0 and Taproot.

ACKs for top commit:
  tcharding:
    ACK 34a5da5f16
  apoelstra:
    ACK 34a5da5f16 nice!

Tree-SHA512: de5717920923e7143e395cbcf143892527e0e794931974eb579db19c17fe0914e630849a0c0581c608909b2cfacfed35df5298605aaa3c9bbd4833985677cf42
2024-06-06 12:52:15 +00:00
Andrew Poelstra 2cfe0e204d
Merge rust-bitcoin/rust-bitcoin#2834: pow: Fix off-by-one error
3298c0c4b5 pow: Unit test from_hex_internal (Tobin C. Harding)
47e4bff0ee pow: Fix off-by-one error (Tobin C. Harding)

Pull request description:

  Patch 1 adds the fix, patch 2 is a unit test that fails if move to the front.

ACKs for top commit:
  apoelstra:
    ACK 3298c0c4b5 nice find! and lucky this just returns an error rather than panicking. may be worth backporting nonetheless
  brunoerg:
    ACK 3298c0c4b5

Tree-SHA512: 15bbd5aa4ac62c91492f5394444d179d95770bae822422bf00bb62896dcaf6c92d32f7d2e3380c352ff7242422ec6af6ff637ff78d14406cd047ef4ad5f22649
2024-06-05 13:18:03 +00:00
Jose Storopoli 34a5da5f16
bitcoin: Add Taproot PSBT multiple inputs examples 2024-06-05 13:11:28 +00:00
Jose Storopoli b8dc0617c9
bitcoin: Add ECDSA PSBT multiple inputs examples 2024-06-05 13:11:25 +00:00
Jose Storopoli a09c3c5225
Check API: remove false positives on rustdoc 2024-06-05 11:44:05 +00:00
Tobin C. Harding 3298c0c4b5
pow: Unit test from_hex_internal
Add a unit test that fails if put before the "pow: Fix off-by-one error"
patch. Tests that we can correctly parse a 32 character long hex string
into a `U256`.
2024-06-05 09:44:23 +10:00
Tobin C. Harding 47e4bff0ee
pow: Fix off-by-one error
Length check has an off-by-one error in it, we want the check it include
hex strings of length 32 (eg, 128 bytes).
2024-06-05 08:39:47 +10:00
Andrew Poelstra 741589c5ad
Merge rust-bitcoin/rust-bitcoin#2828: fuzz: add more coverage for `deserialize_block`
ee30eaa81b fuzz: add more coverage for `deserialize_block` (Bruno Garcia)

Pull request description:

  This PR adds more coverage for the `deserialize_block` target. First, it serializes the block and compares with the data provided and then call some block functions to ensure they run without any issue.

ACKs for top commit:
  apoelstra:
    ACK ee30eaa81b Thanks!

Tree-SHA512: db6c7befa7b429267e9b28fb7910d2b9e8d462e22c791b544b1aa528c7ba4f8e1cd32e1276c67d3da1f97ce484e7ed19ec20b10d2030f2977fd8f855cf510ffe
2024-06-03 13:57:09 +00:00
Tobin C. Harding 4ce7ee179a
Merge rust-bitcoin/rust-bitcoin#2826: Automated daily update to rustc (to nightly-2024-06-02)
5cff6b4765 Automated update to Github CI to rustc nightly-2024-06-02 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 5cff6b4765

Tree-SHA512: 02513ed90221b2a31a3cc839dde89eb0239d3537ce19bd32bbc4541f58469a9d88de57e921fea3d653b0f52405b94677ea4470d469ae5f7ace463611be7cd9cd
2024-06-03 12:09:45 +10:00
Update Nightly Rustc Bot 5cff6b4765 Automated update to Github CI to rustc nightly-2024-06-02 2024-06-03 01:23:52 +00:00
Bruno Garcia ee30eaa81b fuzz: add more coverage for `deserialize_block` 2024-06-02 15:44:35 -03:00