Commit Graph

6535 Commits

Author SHA1 Message Date
ChrisCho-H afd4ec8c5e test: push minimality check for zero(empty) 2025-04-24 20:52:37 +09:00
merge-script 561e3aa026
Merge rust-bitcoin/rust-bitcoin#4385: controlblock::decode unused variant
dedb42dd71 fix(taproot): remove unused error variant - clippy::enum_variant_names allow attribute added - cargo formatting changes reversed (aagbotemi)

Pull request description:

  This PR removed unused variant from `TaprootError`, also allow `clippy::enum_variant_names` attribute for TapError (this will help to prevent Clippy Build Error). Another way to fix the clippy build error is to change the variants name, but I think the attribute is better

  Fixes #4360

ACKs for top commit:
  apoelstra:
    ACK dedb42dd7178774cea6ce92d25d7519de52c2526; successfully ran local tests
  Kixunil:
    ACK dedb42dd71

Tree-SHA512: ff4c2cb5a8e22a05147db15afc449494460ae788a9cb644cc1140cf1b30777a2ac7b5921113da0dc745471357c081793b32e879e6ff29f9bd5769d0ff9292dd8
2025-04-23 17:19:11 +00:00
aagbotemi dedb42dd71
fix(taproot): remove unused error variant
- clippy::enum_variant_names allow attribute added
- cargo formatting changes reversed
2025-04-23 15:51:09 +01:00
Shing Him Ng a92cc71f65 Create impl_mul_assign and impl_div_assign macros
The macros were called on type-rhs pairs that have an existing
implementation of ops::Mul and ops::Div, respectively, that have an
`Output` of `Self`
2025-04-22 22:50:09 -05:00
merge-script 319e87c07c
Merge rust-bitcoin/rust-bitcoin#4376: primitives: replace error propagation with `expect`
cf42c511d8 primitives: replace error propagation with `expect` (Andrew Poelstra)

Pull request description:

  This error path cannot happen, and if it could, failing formatting is not the correct source of action, because the std docs say that formatting may only fail if the formatter says so.

  Fixes comment in #4269

ACKs for top commit:
  tcharding:
    ACK cf42c511d8
  Kixunil:
    ACK cf42c511d8

Tree-SHA512: 0ad47bb210dc71568bde426b8fd7782a4d48415fbf27133783975117d174b58eb791e68290e53f150a7e65236efda75032852bb6ed30bf4a182f18b9440cfcf9
2025-04-22 18:48:53 +00:00
merge-script 9c80eb077a
Merge rust-bitcoin/rust-bitcoin#4365: Implement FromIterator for Witness
6bd7dc6980 feat(witness): implement FromIterator for Witness with unit test (aagbotemi)

Pull request description:

  This PR implements the FromIterator trait for the Witness struct, addressing issue #4351.

  Changes:
  - Added FromIterator<T: AsRef<[u8]>> implementation for Witness, allowing for convenient creation of Witness from iterators
  - Added unit test to verify the implementation works correctly

  This PR fixes #4351

ACKs for top commit:
  tcharding:
    ACK 6bd7dc6980
  apoelstra:
    ACK 6bd7dc69802ad809492fe44d8d87c4b287f93676; successfully ran local tests

Tree-SHA512: 660196c5027fb9270f9ae5c4e08eab6baa2afbdf19a2220b4777303f71f6802bd7ed5e1512af8ee14654b1249ec22606ea817951befbe85b13f9f285b3ebae12
2025-04-22 16:48:23 +00:00
Andrew Poelstra a66ad97fb6
bip32: split InvalidChildNumber and InvalidChildNumberFormat out of error
Currently in this module we have a distinction between an "index" which
is a number between [0, 2^31 - 1] which indexes into the set of normal
or hardened child numbers. We also have a child *number*, which within
the library is an opaque type, but can be freely converted into/out of a
u32 in the consensus encoding which uses the MSB as a normal/hardened
flag and the other bits to encode the index.

Probably we want to change ChildNumber::From<u32> to some sort of
from_consensus_u32 method, but that's out of scope for this PR. What is
*in scope*, though is fixing the error types.

In the existing code we have three problems:

* Our error type for a bad index is called InvalidChildNumber, rather
  than InvalidIndex, and the error message reflects this, which is wrong
  and confusing. (Some with InvalidChildNumberFormat.)
* The InvalidChildNumberFormat is always constructed from a ParseIntError
  from stdlib, but we always throw that away rather than preserving it.
* These two error variants only appear when parsing child numbers, or
  derivation paths which are lists of child numbers, but they are part
  of the main error enum.
2025-04-22 14:46:34 +00:00
Andrew Poelstra a891fb9b74
bip32: remove unused error variants 2025-04-22 14:46:18 +00:00
Andrew Poelstra f0a237c001
bip32: split out DerivationError from the main error enum
This is a breaking change to the API of the deprecated `derive_pub`
function, but it's in a way that's unlikely to break consumers (who are
probably just .expect'ing the result) so we will retain the deprecated
function.
2025-04-22 14:45:57 +00:00
Andrew Poelstra 32d96f6c33
bip32: make Xpriv::new_master be infallible
The only error path for this is cryptographically unreachable and was
removed in a previous commit.
2025-04-22 14:45:36 +00:00
Andrew Poelstra 0e5e021b69
bip32: change several cryptographically unreachable paths to expects
These paths cannot be reached. In general, key derivation cannot fail
for cryptographic reasons.
2025-04-22 14:44:46 +00:00
Bilog WEB3 3c6f45294b
fix typo in serialized_signature.rs 2025-04-22 16:15:02 +02:00
Jamil Lambert c4d9c1b9f8
Use a consistent rustdoc heading level of H1 `#`
There was and inconsistent usage of `#`, `##` and `###` in rustdoc
headings.  The difference in the rendered rustdocs is a minimal font
size change.

Change all headings to be H1 `#`.

Change all subheadings to be `###` to have a noticeable difference in
font size in the rendered docs.
2025-04-22 13:06:32 +01:00
Jamil Lambert 6325a7cdea
Change rustdoc heading level of references
`Bitcoin Core References` used H3 `###` in rustdocs, and one occurrence
had another `References` heading above it.

Change them to be H1 `#` like other headings.

Remove the redundant `References` heading.  NB. there are no other
occurrences of `# References` in this crate.
2025-04-22 12:55:48 +01:00
Jamil Lambert f22e997587
Use parameters instead of arguments in rustdocs
The rustdocs use both `# Parameters` and `# Arguments` to mean the same
thing.

Change all of them to `# Parameters` to be consistent.
2025-04-22 10:43:13 +01:00
Jamil Lambert e2c7be6d2f
Fix typo 2025-04-22 10:39:43 +01:00
aagbotemi 9eaaf114b0
fix(witness): remove explicit type 2025-04-22 04:55:48 +01:00
aagbotemi 5b572c5976
docs(witness): use constructs instead of creates 2025-04-22 04:28:51 +01:00
Shing Him Ng 6370aac7e1 Make Version::maybe_non_standard and Version::is_standard const 2025-04-21 22:06:56 -05:00
aagbotemi 6bd7dc6980
feat(witness): implement FromIterator for Witness with unit test 2025-04-22 02:10:27 +01:00
merge-script ddd27eddc4
Merge rust-bitcoin/rust-bitcoin#4377: fix errors input.rs
55119c6a7b fix errors input.rs (Fallengirl)

Pull request description:

  hey team ! I found simple errors and fixed them
  HSAH160 - HASH160
  HAS256 - HASH256

ACKs for top commit:
  apoelstra:
    ACK 55119c6a7bdb92538728033652dc4d6a6c0a9220; successfully ran local tests

Tree-SHA512: 6f803ea290b4b7c3eb68fcea94fa5956bbe587c428a64c12388122a1c5c8d0a30489467bf464a6b701524990fbe4a9046072cbf6ec6800594c0e590d10744784
2025-04-21 23:14:55 +00:00
Fallengirl 55119c6a7b
fix errors input.rs 2025-04-21 23:23:59 +02:00
Andrew Poelstra cf42c511d8
primitives: replace error propagation with `expect`
This error path cannot happen, and if it could, failing formatting is
not the correct source of action, because the std docs say that
formatting may only fail if the formatter says so.

Fixes comment in #4269
2025-04-21 21:16:46 +00:00
merge-script 2d8ebb79c3
Merge rust-bitcoin/rust-bitcoin#4375: Add ControlBlock constructor that takes a hex string
3319e6ef6d Add ControlBlock constructor that takes a hex string (Shing Him Ng)

Pull request description:

  Closes #4362

ACKs for top commit:
  Kixunil:
    ACK 3319e6ef6d
  apoelstra:
    ACK 3319e6ef6dd964f40e6e880843648c112a6b74ed; successfully ran local tests

Tree-SHA512: 230e4607402b3df6a8c5fe1e03209573baffbd08ca9d28e1208bff1464668a083ddb5ae72781eceb2546bc99b150dd2f832d122570d55aa323c603481c5eff93
2025-04-21 16:57:41 +00:00
merge-script 4a5ea9af53
Merge rust-bitcoin/rust-bitcoin#4370: Accessing XOnlyPublicKey from bitcoin::taproot
87d1210156 accessing XOnlyPublicKey from bitcoin::taproot (aagbotemi)

Pull request description:

  This PR fixes #4363

  `XOnlyPublicKey` is now made available from `bitcoin::taproot`.

ACKs for top commit:
  apoelstra:
    ACK 87d1210156f6a39b1e59f098bc520dba6f02a5b4; successfully ran local tests

Tree-SHA512: 7ea0ee330d32e5413d06deb70d920396ebd275ce65841d6eadac318aab4e728629c57c828722df4e1cb3130bb72f4170f32218ec25ec243d99f0094094d8f9da
2025-04-21 15:33:07 +00:00
merge-script 353992f33a
Merge rust-bitcoin/rust-bitcoin#4368: test: add test for push slice minimal
2b37583ca5 test: add test for push slice minimal (ChrisCho-H)

Pull request description:

  Following https://github.com/rust-bitcoin/rust-bitcoin/pull/4322.
  Test `push_slice` and `push_slice_nom_minimal` from OP_1...OP_16 and OP_1NEGATE.

ACKs for top commit:
  apoelstra:
    ACK 2b37583ca55195965ce2f129d75a1fc114d8b5f6; successfully ran local tests

Tree-SHA512: 6d8e96d522d317d7ede2f1bc133050d98ccbc1816c59fe3589003de249828367314f751d3a75d6b58b0c90b1b735f85650c0d7acebaf5da21a38fb651ab4177d
2025-04-21 14:54:24 +00:00
merge-script b67b9de765
Merge rust-bitcoin/rust-bitcoin#4369: Rename `try_into_taptree` to `try_into_tap_tree`
73317c1c31 rename try_into_taptree into try_into_tap_tree - docs(taproot): hide deprecated try_into_taptree (aagbotemi)

Pull request description:

  The PR introduces a new function `try_into_tap_tree()` to replace `try_into_taptree()`. `try_into_taptree()` has been deprecated.

  This PR fixes #4364

ACKs for top commit:
  apoelstra:
    ACK 73317c1c31271b65eb50c45353bf7393eba1154b; successfully ran local tests

Tree-SHA512: 5d853ea05a8cacfc0a27a93bed4351409abf5f93e53b308d62efdc3966c8403a4a857e39882eb84e511b637763ddb9629be832c2079057d81fa1c1984bcb8ad7
2025-04-21 14:21:58 +00:00
merge-script 3e6de4604e
Merge rust-bitcoin/rust-bitcoin#4366: Deserialize witness from a list of hex strings
e0b627ea81 deserialize witness from a list of hex strings - ci(primitives): enable hex feature in CI build - from_hex() implemented more efficiently (aagbotemi)

Pull request description:

  This PR implements `from_hex` function for deserialize `Witness` from a list of hex strings. Added unit test.

  This PR fixes #4350

ACKs for top commit:
  apoelstra:
    ACK e0b627ea816a730949cdb200105598600fcac094; successfully ran local tests
  tcharding:
    ACK e0b627ea81

Tree-SHA512: deec3f9e5f67a0915b11a811c40c341dd9f24d0394d6cfbd6a09f765ce3fc0dcce2740949c264d4aa2d2db748a5ce81416b4dac15b1b64475a7c024b205e40ab
2025-04-21 13:36:56 +00:00
Shing Him Ng 3319e6ef6d Add ControlBlock constructor that takes a hex string 2025-04-20 23:13:01 -05:00
merge-script fa2cda8513
Merge rust-bitcoin/rust-bitcoin#4371: Allow using the 'base64' feature in `no_std` environments
418445f26b Allow using the 'base64' feature in no_std environments (Salvatore Ingala)

Pull request description:

  Gating like the other features should do the trick.

ACKs for top commit:
  apoelstra:
    ACK 418445f26bc344546c756d9a1991f4e2e75da745; successfully ran local tests; nice!
  Kixunil:
    ACK 418445f26b

Tree-SHA512: f21e126302f18a261be3b6a16253901017bf3caaa0c1c2e82681d00355f291a5772c793bf376e5746aa2afcc0c8b2c2f85a11ae6f6a90e6fc4e732ce4db89ee7
2025-04-20 21:31:33 +00:00
merge-script 8276e4d0e5
Merge rust-bitcoin/rust-bitcoin#4372: Automated nightly rustfmt (2025-04-20)
2c1ce53deb 2025-04-20 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 2c1ce53deb2fb2dc56546c9151c5fb61520f4713; successfully ran local tests

Tree-SHA512: 566535deece199d3a19910d6b033f8bf3ddbce27092f218041ebb1694b5f6184e4851ae9a54ddd0887c56f73e8083441e1769785109688c3c6f2a57120805229
2025-04-20 20:11:56 +00:00
merge-script aa804ee1b1
Merge rust-bitcoin/rust-bitcoin#2456: Use InputWeightPrediction to calculate effective_value
f6105ea417 Use InputWeightPrediction to calculate effective_value (yancy)

Pull request description:

  closes: https://github.com/rust-bitcoin/rust-bitcoin/issues/2455

  Also, what about moving `effective_value` to `InputWeightPrediction`?

  Marking as a draft until we can add api changes again.

ACKs for top commit:
  apoelstra:
    ACK f6105ea4171a85ce21443d7eb76b7aa9cadab53a; successfully ran local tests; yeah, this API does look nicer
  Kixunil:
    ACK f6105ea417

Tree-SHA512: 20592e49cb93343b1aefa340c3c870e2e21c747711da68a6aa57342f59ff2981c30e9c91de7eab32bcd11da33f040f9df62008db991d93b549079f91a6908055
2025-04-20 19:36:22 +00:00
merge-script 8ca3a430c7
Merge rust-bitcoin/rust-bitcoin#4336: units: Make minor improvements to `MathOp`
0f62c9a582 units: Make minor improvements to MathOp (Tobin C. Harding)

Pull request description:

  Follow up from #4312, improve the `MathOp` type by:

  - Do not provide public constructor
  - Add cast protection

ACKs for top commit:
  apoelstra:
    ACK 0f62c9a5822a813be5c6f6b19d160458243f174a; successfully ran local tests
  Kixunil:
    ACK 0f62c9a582

Tree-SHA512: dbb06c5afd8df5364a2aec12b7c8632620a1e8f3955b83e91a9b4f5c2e0daaa1ecdb050d8e395e95bf018d718847cddbf3338bd89f70cbb0382bf5e080d5cf21
2025-04-20 16:35:47 +00:00
aagbotemi e0b627ea81
deserialize witness from a list of hex strings
- ci(primitives): enable hex feature in CI build
- from_hex() implemented more efficiently
2025-04-20 15:53:52 +01:00
Fmt Bot 2c1ce53deb 2025-04-20 automated rustfmt nightly 2025-04-20 01:36:29 +00:00
Salvatore Ingala 418445f26b
Allow using the 'base64' feature in no_std environments 2025-04-19 19:31:11 +02:00
aagbotemi 73317c1c31
rename try_into_taptree into try_into_tap_tree
- docs(taproot): hide deprecated try_into_taptree
2025-04-19 16:54:01 +01:00
aagbotemi 87d1210156
accessing XOnlyPublicKey from bitcoin::taproot 2025-04-19 16:26:19 +01:00
ChrisCho-H 2b37583ca5 test: add test for push slice minimal
Test push_slice and push_slice_nom_minimal from OP_1...OP_16 and OP_1NEGATE
2025-04-19 14:23:31 +09:00
merge-script c85648cfd4
Merge rust-bitcoin/rust-bitcoin#4322: fix: enforce standard minimal push for push_slice
354e1e42ad fix: enforce minimal push for push_slice (ChrisCho-H)

Pull request description:

  Currently `push_slice` doesn't check the standard minimal push rule, which could result in possible money loss(e.g. if non minimal push is used in output script of p2wsh or p2tr).
  Introduce `push_slice_non_minimal` to provide the way to push as now, and change `push_slice` logic to follow standard minimal push rule.

  99a4ddf5ab/src/script/script.cpp (L366)

ACKs for top commit:
  tcharding:
    ACK 354e1e42ad
  apoelstra:
    ACK 354e1e42ad98c7968827d03be563bc14d764a983; successfully ran local tests

Tree-SHA512: 01f53dbd2a1a3c9a9e4387f0aaa7801f9c4570996054503a38d09ed1646ab65a3249d227adcf4139ac37a111d795e6cf986c4c273d5660c20820d1b36ba46f57
2025-04-18 14:23:53 +00:00
merge-script 89d7b3fe24
Merge rust-bitcoin/rust-bitcoin#4358: Capitalize Taproot in rustdocs
c4ff2baa5a Capitalize Taproot in rustdocs (Jamil Lambert)

Pull request description:

  Some recent additions to the rustdocs used a lowercase t in taproot.

  Capitalize all cases of Taproot in rustdocs to be consistent.

  Closes #4354

ACKs for top commit:
  tcharding:
    ACK c4ff2baa5a
  apoelstra:
    ACK c4ff2baa5a7c841ecdfe0e8a92b0a1a664f203ae; successfully ran local tests

Tree-SHA512: 620ccf769a6dad3bcdfec8a0460f6f1bbf90780e280ca94317f6048117aaad06c41a90cd3ee00d670f799459316c1f84e96e4ce3ef3a44818243b21c2f41924b
2025-04-18 13:04:17 +00:00
merge-script 9b455ffe83
Merge rust-bitcoin/rust-bitcoin#4359: fix `rejectection` to `rejection` message_network.rs
79f6530c86 fix rejectection to rejection message_network.rs (Alex Pikme)

Pull request description:

ACKs for top commit:
  apoelstra:
    ACK 79f6530c864e06316a80dae0842762352527def3; successfully ran local tests

Tree-SHA512: 0b8875780365496ce9621c0ca8bb7617fd458bb618e0bd93607245a9e326509c2a5817b8a650722a54c24ea3cd673345c63d3b4d2ef01ff074e09d2c0e5b235e
2025-04-18 01:38:55 +00:00
merge-script 6241b34afc
Merge rust-bitcoin/rust-bitcoin#4319: units: Implement privacy boundaries
6323867c65 Run the formatter (Tobin C. Harding)
d5c08aef32 units: Update column width (Tobin C. Harding)
f7f1a0be8c Add privacy boundary to BlockTime (Tobin C. Harding)
b3dfe0df3f Add privacy boundary to Weight (Tobin C. Harding)
e1a14b3c2d Add privacy boundary to FeeRate (Tobin C. Harding)
4b733d4dad Run the formatter (Tobin C. Harding)

Pull request description:

  Add privacy boundary for `FeeRate`, `BlockTime`, and `Weight`. The lock times are a bit curly so just doing these ones for now.

ACKs for top commit:
  apoelstra:
    ACK 6323867c65cdbf0f1b25d252fded6873acd35a3a; successfully ran local tests

Tree-SHA512: b6cf5eb032e055414f48f3469ec1748635b9f53ca64c158bd861d1ae6e2cfbe7b4d82de98f7dc90913d98429e6ae6991a4a61b6c438574fcbef9b3bc7ebafb4b
2025-04-17 22:07:20 +00:00
Alex Pikme 79f6530c86
fix rejectection to rejection message_network.rs 2025-04-17 21:13:12 +02:00
Jamil Lambert c4ff2baa5a
Capitalize Taproot in rustdocs
Some recent additions to the rustdocs used a lowercase t in taproot.

Capitalize all cases of Taproot in rustdocs to be consistent.
2025-04-17 18:02:35 +01:00
merge-script 30c1933d16
Merge rust-bitcoin/rust-bitcoin#4347: primitives: Increase test coverage in `Script`
b4b61cb884 Add tests to increase coverage (Jamil Lambert, PhD)
6bcc6b703d Expand display test to cover debug and OP_0 (Jamil Lambert, PhD)
8a096b77d5 Expand as_ref and as_mut tests (Jamil Lambert, PhD)
afa51f7bfa Add missing empty line, and remove extra one (Jamil Lambert, PhD)

Pull request description:

  Expand existing tests and add new ones to increase the test coverage in `primitives/src/script/` to 100% excluding `serde` and `arbitrary` features.

ACKs for top commit:
  apoelstra:
    ACK b4b61cb8849d5d536532474691c5d9f10c146672; successfully ran local tests
  tcharding:
    ACK b4b61cb884

Tree-SHA512: 6c37a194e5a94fe04bb26d4e904bd98efc75bd433b59aa09b1c102df96b753602d3ad6540ed9941827f03c7d38e7bbb8b10bbcc8c6ab52b8f96b83743eec4519
2025-04-17 15:05:33 +00:00
Tobin C. Harding 6323867c65
Run the formatter 2025-04-17 11:43:05 +10:00
Tobin C. Harding d5c08aef32
units: Update column width
Update column width inside the new `encapsulate` modules.

No content change.
2025-04-17 11:43:05 +10:00
Tobin C. Harding f7f1a0be8c
Add privacy boundary to BlockTime
As per policy in #4090 add a privacy boundary to the `BlockTime` type.
Use the module name `encapsulate` as is done in `amount` - its private
so the name can easily be changed later if needed.

Explicitly do not run the formatter or update rustdoc column width so
that review is easier.
2025-04-17 11:43:05 +10:00
Tobin C. Harding b3dfe0df3f
Add privacy boundary to Weight
As per policy in #4090 add a privacy boundary to the `Weight` type. Use
the module name `encapsulate` as is done in `amount` - its private so
the name can easily be changed later if needed.

Explicitly do not run the formatter or update rustdoc column width so
that review is easier.
2025-04-17 11:43:05 +10:00