Commit Graph

2286 Commits

Author SHA1 Message Date
yancy 8552534b61 Use u32 for struct and member variables in IWP, saturating to u32::MAX
To prevent panics during addition if `usize` is `u64`, use `u32` member
variables internally.  TK use `u32::saturating_add` instead of basic
addition. However, to use `u32::saturating_add()`, the variables need
to be of type `u32`. Therefore, this commit transforms the internal
types to `u32`.

In so doing, add a `const` function `saturate_to_u32()` which saturates
a usize to `u32`.  Also, replace `compact_size::encoded_size()` with a new
function `encoded_size()` which returns a `u32`, avoiding needless casts.
2025-06-24 15:03:26 -05:00
merge-script f0302f2ecd
Merge rust-bitcoin/rust-bitcoin#4570: fix(p2p): remove `AddrV2` <> `SocketAddr` conversions
6335c623f6 fix(p2p): remove `AddrV2` <> `SocketAddr` conversions (Luis Schwab)

Pull request description:

  This PR reverts #4521 due to loss/creation of port information during the conversion. Users should use the `AddrV2` <> `IpAddr` conversion instead.

  Closes #4566

ACKs for top commit:
  Kixunil:
    ACK 6335c623f6
  tcharding:
    ACK 6335c623f6

Tree-SHA512: f183756467ca17bb7e7078023a769ec33d3deb4146ab7ec63ef961107ab93ec975c9adffd9eeddc79250abfa1cee9eccbbcaef7466cf4c2c21205b69d8e9eb4f
2025-05-28 14:28:10 +00:00
merge-script 3c8eeeb42a
Merge rust-bitcoin/rust-bitcoin#4562: Remove redundant `ServiceFlags` test
9d956e8643 test: remove redundant `ServiceFlags` test (rustaceanrob)

Pull request description:

  The `ServiceFlags` type is already tested within p2p/mod.rs with a nearly identical test. This type also has nothing to do with `network`

  ref: https://github.com/rust-bitcoin/rust-bitcoin/blob/master/bitcoin/src/p2p/mod.rs#L400

ACKs for top commit:
  tcharding:
    ACK 9d956e8643
  apoelstra:
    ACK 9d956e8643214b3c1ad0e42cc630e2f35f7b7994; successfully ran local tests

Tree-SHA512: d113609070e3df6d44b1ed57c40c1bce251d59fa22eb1abbf6c576fd84e21464553bee7fa97eba000ad9c1b8ef98e2ba04aec7077486273de9b7e54341ba894b
2025-05-28 13:48:43 +00:00
merge-script 0064ad67a6
Merge rust-bitcoin/rust-bitcoin#4557: Move CheckedSum and add Weight
9dac4d69e0 Implement CheckedSum for Weight iterator (yancy)
0dbcd09bbc Move CheckedSum trait to crate root (yancy)

Pull request description:

  * Move CheckedSum to the crate root so that other types can be added
  * Add Weight to CheckedSum

ACKs for top commit:
  tcharding:
    ACK 9dac4d69e0
  apoelstra:
    ACK 9dac4d69e0f142e9a2dc4b61ea49365a8cae3f4b; successfully ran local tests

Tree-SHA512: 3e4b7f79074e23493ccd17a026542081f0d7a811f4f35edb7994ada95bf414a166531f142ad4986d27fcec448209b2ffa56813b495b5df6b6e8fcd589392e0c1
2025-05-28 04:09:12 +00:00
Luis Schwab 6335c623f6
fix(p2p): remove `AddrV2` <> `SocketAddr` conversions 2025-05-27 10:32:23 -03:00
rustaceanrob 9d956e8643
test: remove redundant `ServiceFlags` test
The `ServiceFlags` type is already tested within p2p/mod.rs with a
nearly identical test. This type also has nothing to do with `network`
2025-05-27 10:09:44 +01:00
yancy 0dbcd09bbc Move CheckedSum trait to crate root
In order to add other types to CheckedSum, remove from the Amount
module.  In so doing, other types added to CheeckSum do not need to be
imported into Amount.
2025-05-26 19:01:42 -05:00
merge-script 5e0b86d2b1
Merge rust-bitcoin/rust-bitcoin#4440: Add support for de/serializing PSBT_{IN,OUT}_MUSIG2_PARTICIPANT_PUBKEYS
2481695b45 Add tests for BIP-373 PSBT_{IN,OUT}_MUSIG2_PARTICIPANT_PUBKEYS serialization and deserialization (Daniel Roberts)
3e8e6d9aa1 Add BIP-373 PSBT_{IN,OUT}_MUSIG2_PARTICIPANT_PUBKEYS serialization and deserialization (Daniel Roberts)

Pull request description:

  This change adds support for serializing and deserializing two PSBT keys from BIP-373: `PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS` and `PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS`

  This is a part of #4207 that can be implemented independently of the rest (which depends on https://github.com/rust-bitcoin/rust-secp256k1/pull/716). I believe this satisfactorily avoids changing things multiple times on end users, *however* it's not *completely* transparent to end users, since any code that currently accesses these fields through `unknown` will need to be updated. Later, when `PSBT_IN_MUSIG2_PUB_NONCE` and `PSBT_IN_MUSIG2_PARTIAL_SIG` are supported, code will need to be updated a second time to retrieve them from the correct place instead of `unknown`. I'm of the opinion that this imposes a very minor maintenance burden, only consisting of *removing* deserialization code.

  ### Notes/Requests for feedback

  - For the most part I used my judgement rather than `cargo fmt` since `cargo fmt` already had a lot of other complaints, but of course I'll update if I need to.
  - To satisfy the requirement that every commit pass tests, the commit updating the psbt serde regression test should probably be squashed into the first commit, but I just wanted to confirm that before I did it. I suppose similarly, the test commit could be squashed as well?
  - I waffled between `musig2_participants` and `musig2_participant_pubkeys`, but I've decided to go with `musig2_participant_pubkeys` because that is consistent with Bitcoin Core

ACKs for top commit:
  tcharding:
    ACK 2481695b45
  apoelstra:
    ACK 2481695b456bcccbb25c247c1fd39bbda24dbb30; successfully ran local tests

Tree-SHA512: af884923593c9cbb24ff3f1f08219458538592fabde85d5d65bc2d9bc7bf0b1a73dac38d2c56303b4f3162088db129ea7e879c3d4b324e965933c121ef939a07
2025-05-26 19:17:48 +00:00
yancy 8dd24cb67b Add Arbitrary type for InputWeightPrediction
This type creates sane Arbitrary InputWeightPrediction types that do
not panic.  To this end, when a custom type is created by calling new()
or from_slice() constructor, only use values that would no greater than
block size 4 Mwu.
2025-05-25 13:15:56 -05:00
merge-script 0432102472
Merge rust-bitcoin/rust-bitcoin#4549: Add trait to InputWeightDescription
07c4f76052 Add comparison traits to InputWeightPrediction (yancy)

Pull request description:

  * Partial Eq is added to Enable symmetric and transitive comparison.
  * Eq is added to enable reflexive comparison.

ACKs for top commit:
  apoelstra:
    ACK 07c4f760523b7a196bf160f585c2b437dea5b532; successfully ran local tests
  tcharding:
    ACK 07c4f76052

Tree-SHA512: baeb957f000ac0f3be89166243b9cc7126daad06ad6688b811037ca5f5713cad1184c7135b2f4f32235457c0f53eb41304846bdd8a84e57b10a6eff0905224e8
2025-05-25 14:42:56 +00:00
Daniel Roberts 2481695b45 Add tests for BIP-373 PSBT_{IN,OUT}_MUSIG2_PARTICIPANT_PUBKEYS serialization and deserialization 2025-05-25 08:28:16 -05:00
Daniel Roberts 3e8e6d9aa1 Add BIP-373 PSBT_{IN,OUT}_MUSIG2_PARTICIPANT_PUBKEYS serialization and deserialization 2025-05-25 08:28:16 -05:00
Fmt Bot c73131c8f0 2025-05-25 automated rustfmt nightly 2025-05-25 01:42:57 +00:00
merge-script ecf4b2bcee
Merge rust-bitcoin/rust-bitcoin#4496: BREAKING: Change Psbt serde implementations
9aa235c24d BREAKING: Change Psbt serde implementations (Daniel Roberts)
d7e9a84339 Fix Psbt preimage keys in serde test (Daniel Roberts)
62026c1e2d Don't use PSBT_GLOBAL_XPUB as an unknown key in Psbt serde test (Daniel Roberts)

Pull request description:

  Implements the conclusion of #3454 by serializing Psbts using the BIP-174 binary encoding, optionally using base64 where appropriate.

  The core of the problem is the old derived serde implementation by its nature can't be backwards compatible when serialized in binary formats like bincode. Fields will be added to the Psbt (my motivating case in #4440 ) and this will always break formats like bincode.

ACKs for top commit:
  apoelstra:
    ACK 9aa235c24d65d23de2afc21fcbd019892bf4ad2a; successfully ran local tests
  tcharding:
    ACK 9aa235c24d

Tree-SHA512: 4dc9dbf1a71f06769d74fada7e3d5557a3df3ee78769c66c2d8480c434baa0abd2efba555137563af58da2cc1d545813eb43b6c696b363a5777a9836bc1b7382
2025-05-24 16:03:33 +00:00
yancy 07c4f76052 Add comparison traits to InputWeightPrediction
* Partial Eq is added to Enable symmetric and transitive comparison.
* Eq is added to enable reflexive comparison.
2025-05-24 07:35:25 -05:00
merge-script 1c07916777
Merge rust-bitcoin/rust-bitcoin#4538: Use `_u32` in `FeeRate` constructor instead of `_unchecked`
a1ce2d1ac8 Use _u32 in FeeRate constructor instead of _unchecked (Tobin C. Harding)

Pull request description:

  When constructing an `Amount` it was observed recently that a `u32` is often big enough. For the same reason we can use a `u32` to construct a fee rate instead of overflowing.

  Use `_u32`in the constructor and remove the panic.

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

Tree-SHA512: 339974c954ad613b0be684f7b2fa1402f59fe401969f3785a702ffbb14ac913ecf4c8228240d068ba4b482e38263590154167a071d823ccc9b4d0691036ca484
2025-05-23 16:18:59 +00:00
merge-script 2f2c9144ba
Merge rust-bitcoin/rust-bitcoin#4526: feat(p2p): add AddrV2 <> IpAddr conversions
3c920d1acb fix(p2p): Remove `SocketAddr::V6` <> `AddrV2::Cjdns` conversions (Erick Cestari)
2c236ae24f fuzz: Add p2p address round-trip fuzzing test (Erick Cestari)
7ad89df392 test(p2p): add tests for `AddrV2` <> `IpAddr` conversions (Erick Cestari)
e8a9a89e25 feat(p2p): add `AddrV2` <> `IpAddr` conversions (Erick Cestari)

Pull request description:

  This PR adds conversion traits between `AddrV2` and standard IP types, inspired by #4519.

  ### Changelog

  - Implement `From<IpAddr>` for `AddrV2`.
  -  Implement `From<Ipv4Addr>` for `AddrV2`.
  -  Implement `From<Ipv6Addr>` for `AddrV2.`
  - Implement `TryFrom<AddrV2>` for `IpAddr`.
  - Implement `TryFrom<AddrV2>` for `Ipv4Addr`.
  - Implement `TryFrom<AddrV2>` for `Ipv6Addr`.
  - Implement `AddrV2ToIpAddrError` enum and it's `fmt::Display`.
  - Implement `AddrV2ToIpv4AddrError` enum and it's `fmt::Display`.
  - Implement `AddrV2ToIpv6AddrError` enum and it's `fmt::Display`.
  - Renamed `AddrV2ConversionError` to `AddrV2ToSocketAddrError`
  - Tests for `TryFrom` conversions.

ACKs for top commit:
  apoelstra:
    ACK 3c920d1acb23d84976c0b8e632d8f1068ebbd1fd; successfully ran local tests
  tcharding:
    ACK 3c920d1acb

Tree-SHA512: 6bc8007252ac78fba8dff5de59bbd4134f0dc1f801cdf23676b9b1ea256558cb7ddca81f932cccba7fc34e70d204184f0f9e5f18e4485bd922196fb5f78fd588
2025-05-23 14:56:21 +00:00
Daniel Roberts 9aa235c24d BREAKING: Change Psbt serde implementations
Replace derived Psbt serde implementation with one that conforms to
BIP-174. In human readable serde contexts, serialize to the base64
encoded format, and in binary serde contexts, serialize to the raw
binary format.

The previous derived serde implementation cannot be used in a backward or
forward compatible way in binary formats like bincode, which means that
every field added to the Psbt struct would break serde de/serialization
into binary formats. Instead, this one-time breaking change will fix the
issue going forward.

Downstream users with persisted data in the old serde format should continue
using 0.32.x to create migrations to the new format.
2025-05-22 16:41:05 -05:00
Daniel Roberts d7e9a84339 Fix Psbt preimage keys in serde test
The preimage values in the serde Psbt don't actually correspond to the
hash keys they should in the serde test. This doesn't cause an error
currently because the derived serde implementation doesn't enforce their
validity during deserialization, but it will when the serde
implementation is modified to use the BIP-174 format.
2025-05-22 16:40:23 -05:00
Daniel Roberts 62026c1e2d Don't use PSBT_GLOBAL_XPUB as an unknown key in Psbt serde test
The previous test used global key id 1 which is not unknown, it's PSBT_GLOBAL_XPUB.
That's an inconsistent state for a Psbt to be in, and will cause a
deserialization error when the Psbt serde implementation is modified to
use the BIP-174 format.
2025-05-22 16:38:57 -05:00
Tobin C. Harding 7e67737393
Use / to divide fee by weight
Looks like this code was written before we added support for dividing
`Amount` by `Weight`.

Refactor, no logic change.
2025-05-22 10:48:08 +10:00
Tobin C. Harding a1ce2d1ac8
Use _u32 in FeeRate constructor instead of _unchecked
When constructing an `Amount` it was observed recently that a `u32` is
often big enough. For the same reason we can use a `u32` to construct a
fee rate instead of overflowing.

Use `_u32`in the constructor and remove the panic.
2025-05-22 10:47:34 +10:00
Erick Cestari 3c920d1acb
fix(p2p): Remove `SocketAddr::V6` <> `AddrV2::Cjdns` conversions 2025-05-21 16:49:27 -03:00
Erick Cestari 7ad89df392
test(p2p): add tests for `AddrV2` <> `IpAddr` conversions 2025-05-21 16:49:27 -03:00
Erick Cestari e8a9a89e25
feat(p2p): add `AddrV2` <> `IpAddr` conversions 2025-05-21 16:49:20 -03:00
merge-script fa52a31ace
Merge rust-bitcoin/rust-bitcoin#4527: Automated nightly rustfmt (2025-05-18)
d9ec934251 2025-05-18 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:
  tcharding:
    ACK d9ec934251
  apoelstra:
    ACK d9ec93425102a014fc495d0918f40ff0f3629e2b; successfully ran local tests

Tree-SHA512: 9f1914af1375443e421ab5309ef8af0f64aa0b3dd03a4cde15b8315d1453f43f35533ae31a7295a83599e7e5ce081149c97f63bbab21e371d60b9401baecc941
2025-05-20 14:43:01 +00:00
merge-script 9310942888
Merge rust-bitcoin/rust-bitcoin#4529: psbt: replace the fee rate magic numbers with named constants in tests
ade7ea5fcf psbt: replace the fee rate magic numbers with named constants in tests (frankomosh)

Pull request description:

  Replace a hardcoded fee rate numbers in PSBT high-fee checks test with named constants.

  Close #4378

ACKs for top commit:
  tcharding:
    ACK ade7ea5fcf
  apoelstra:
    ACK ade7ea5fcfc1d00a7cb3c35b4022a4543a7efe1d; successfully ran local tests

Tree-SHA512: fa02217940ae32f00164c762c82ecb6bd28da58e5ad44165124a7ad44367d7d0f752e7ab189b991edb2460c449bbd0a83df16a47b082f6755bd9e9d38e398cd8
2025-05-19 17:48:54 +00:00
merge-script 0160ac59ce
Merge rust-bitcoin/rust-bitcoin#4512: Remove Display/FromStr for FeeRate
29b12bec6b Remove Display/FromStr for FeeRate (Tobin C. Harding)

Pull request description:

  Parsing and displaying strings is a PITA. `FeeRate` is likely not that heavily used at the moment and users can always just call `to_sat_per_kwu()` to format it.

  So we can get the `units-1.0-alpha.0` release out the door just remove the `Display` and `FromStr` impls for now. They can be added back in later when we have time to get #4339 in.

ACKs for top commit:
  apoelstra:
    ACK 29b12bec6b34148d6df9a4e6207132a667c53b4c; successfully ran local tests

Tree-SHA512: ffb49ab5d4f98be603eb1ca2f2e9d28ff7eaae66607eb9d2d5fef1f98ba2ac284a0007a86c3cae88f06e5b44f1e3e3ecb2014323b82ad4007e8ec59d6d04759b
2025-05-19 14:06:53 +00:00
frankomosh ade7ea5fcf psbt: replace the fee rate magic numbers with named constants in tests
Replace a hardcoded fee rate numbers in PSBT high-fee checks test with named
constants.

Close #4378
2025-05-18 22:04:41 +03:00
Fmt Bot d9ec934251 2025-05-18 automated rustfmt nightly 2025-05-18 01:40:39 +00:00
merge-script e541221950
Merge rust-bitcoin/rust-bitcoin#4521: feat(p2p): add `AddrV2` <> `SocketAddr` conversions
a1d4bc31e5 test(p2p): add tests for `AddrV2` <> `SocketAddr` conversions (Luis Schwab)
64387f566e feat(p2p): add `AddrV2` <> `SocketAddr` conversions (Luis Schwab)

Pull request description:

  Closes #4436.

  Note: I made the `AddrV2::Cjdns` to `SocketAddr` conversion throw the `CjdnsNotRecommended` error. Do we want this behavior or just assume the user knows what he is doing? cc Kixunil

  ### Changelog
  - Implement `From<SocketAddr> for AddrV2`.
  - Implement `TryFrom<AddrV2> for SocketAddr`.
  - Implement `AddrV2ConversionError` enum and it's `fmt::Display`.
  - Tests for these conversions.

ACKs for top commit:
  apoelstra:
    ACK a1d4bc31e5c7cfe0227db64aec8671efcc0c6677; successfully ran local tests
  tcharding:
    ACK a1d4bc31e5

Tree-SHA512: c11f3053428d2c8ca971bbc6bc4ad4619260fe95cba055586f4889d7397733f7d286dcafa111234a6be4a739fd56cdd7e64dbf71b106a71d2483794ca7018105
2025-05-17 18:23:56 +00:00
merge-script 8985c9e5c4
Merge rust-bitcoin/rust-bitcoin#4522: fix(taproot): raname `from_key_and_tweak` to `from_key_and_merkle_root`
d74eede260 fix(taproot): raname `from_key_and_tweak` to `from_key_and_merkle_root` (Luis Schwab)

Pull request description:

  Closes #4236.

  ### Changelog
  - Rename `TapTweakHash::from_key_and_tweak` to `TapTweakHash::from_key_and_merkle_root`. The naming was just wrong, since a TapTweak takes in a public key and a Merkle root to produce a tweak.

ACKs for top commit:
  apoelstra:
    ACK d74eede26064a40d70c7aeb3335b9a4a28eb6bd9; successfully ran local tests
  tcharding:
    ACK d74eede260

Tree-SHA512: 03fdb73758f965290c083165b23a0345325e475f159aa76ff141a9aa3251960041366ddf195b74cada7b289d4493190cf9b17130736002d48b6fac68941012fb
2025-05-17 11:54:47 +00:00
Luis Schwab d74eede260
fix(taproot): raname `from_key_and_tweak` to `from_key_and_merkle_root` 2025-05-16 19:51:59 -03:00
Tobin C. Harding 29b12bec6b
Remove Display/FromStr for FeeRate
Parsing and displaying strings is a PITA. `FeeRate` is likely not that
heavily used at the moment and users can always just call
`to_sat_per_kwu()` to format it.

So we can get the `units-1.0-alpha.0` release out the door just remove
the `Display` and `FromStr` impls for now. They can be added back in
later when we have time to get #4339 in.
2025-05-17 08:20:17 +10:00
merge-script e619364f5c
Merge rust-bitcoin/rust-bitcoin#4503: Fix up script to/from hex
2c0f388108 Fix up script to/from hex (Tobin C. Harding)

Pull request description:

  We (I) have recently done to PRs patching the way we handle converting scripts to and from hex.

  In doing these I made a mess of the deprecation because after both PRs were in I had managed to change the return type and the behaviour of the deprecated function.

  On top of that the docs were either outright wrong or not that clear.

  Props to Kix for doing post merge review and finding my mistakes.

  Close #4498

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

Tree-SHA512: 8bd8590c07efdbfcf113bfcb4b96dc01992c4f215a11e4a1b1f907c8ae9fa47d83c29298bd9b2afc2628b12eb51afd023a48f241a456a0e02a37854b41f6654b
2025-05-16 19:14:34 +00:00
Luis Schwab a1d4bc31e5
test(p2p): add tests for `AddrV2` <> `SocketAddr` conversions 2025-05-15 21:42:54 +00:00
Luis Schwab 64387f566e
feat(p2p): add `AddrV2` <> `SocketAddr` conversions 2025-05-15 21:21:21 +00:00
Tobin C. Harding 2c0f388108
Fix up script to/from hex
We (I) have recently done to PRs patching the way we handle converting
scripts to and from hex.

In doing these I made a mess of the deprecation because after both PRs
were in I had managed to change the return type and the behaviour of the
deprecated function.

On top of that the docs were either outright wrong or not that clear.

Props to Kix for doing post merge review and finding my mistakes.
2025-05-14 10:29:29 +10:00
yancy 642c414f56 refactor: Use map combinator instead of match 2025-05-13 15:49:44 -05:00
merge-script bc93498b3e
Merge rust-bitcoin/rust-bitcoin#4485: Add `Builder::with_capacity()`
d003d48592 Add `Builder::with_capacity()` (Daniel Roberts)
e492f94289 Update `ScriptBuf::with_capacity` docs (Daniel Roberts)

Pull request description:

  Enable the creation of `bitcoin::script::Builder` with a preallocated capacity.

  This is pretty minor, but it provides a small speedup if used correctly. I've observed a 0.4% speedup and a 0.7% speedup in two code bases that create lots of outputs (on the order of tens to hundreds of thousands). It provided a much larger speedup (5% or so) in the latter code base before some other optimizations dwarfed it.

  I have a branch that also uses it for `ScriptBufExt::new_*()` but while it provides a small performance improvement for all script types except one, `ScriptBufExt::new_p2tr()` actually causes a small performance regression. Since the only use case I have for creating lots and lots of scripts is in taproot with CHECKTEMPLATEVERIFY, I'm holding back that change if/until I figure out what's going on exactly (and hopefully resolve it).

ACKs for top commit:
  tcharding:
    ACK d003d48592
  apoelstra:
    ACK d003d4859251abb01929ccab6009a02e0c96b0cd; successfully ran local tests

Tree-SHA512: 51137574ca3d9dc5c319df124f470abd0f82413c093a5636af0439eb0fc2ad01dcf83df366a02279fc7d28feed24aa8c7db33b3c474d8bde7a9b6636343f8e9a
2025-05-13 17:16:54 +00:00
merge-script 525e1a4d1f
Merge rust-bitcoin/rust-bitcoin#4495: test: Add constructor test
3fbd6fb6b3 test: Add constructor test (yancy)

Pull request description:

  The constructor currently has no test coverage.

ACKs for top commit:
  apoelstra:
    ACK 3fbd6fb6b3c6dc1f1d5c14b3f3486140a781d0f0; successfully ran local tests
  tcharding:
    ACK 3fbd6fb6b3

Tree-SHA512: 9819bd058b84a7b633279d12da48c9af7af765fd8dca5d297787872badc431769c026e57b03bf6d907c89a7b7a5c116cda1be98cb6261dd2a6c331276e627cc3
2025-05-13 16:40:00 +00:00
merge-script c3ee5f8491
Merge rust-bitcoin/rust-bitcoin#4478: test: push int minimality
873880b192 test: push int minimality (ChrisCho-H)

Pull request description:

  Integrate the minimality test of `push_int` into that of `push_slice`. This increases test coverage.

ACKs for top commit:
  apoelstra:
    utACK 873880b192
  tcharding:
    ACK 873880b192

Tree-SHA512: 8bbd0b7ec4c69faaadb9ab4bae7429bbebd66d1d718b80f19b323a1059a983ea1b41f743a920b6fdacce213e66708ed1028227246021457601bce968b8bf3f22
2025-05-13 13:47:43 +00:00
ChrisCho-H 873880b192 test: push int minimality
Integrate the minimality test of push_int into that of push_slice. This increases test coverage.
2025-05-13 11:54:14 +09:00
merge-script a8e85b61aa
Merge rust-bitcoin/rust-bitcoin#4472: Change the return type of effective_value
b038520c4d Change the return type of effective_value (yancy)

Pull request description:

  Prefer the more informative return type NumOpResult over Option.  Also a returns section was added which describes the different possible returns.

  The api of NumOpResult could probably be extended to cleanup the match statement.  Also consider api addition for unchecked calculations natively.

ACKs for top commit:
  tcharding:
    ACK b038520c4d
  apoelstra:
    ACK b038520c4dc8c2f92cb40a9fd272608ae2e9b799; successfully ran local tests

Tree-SHA512: 2e66a3ca83514f0ad011660178f8e5ea9d9b1de03dc030e7c57f558e08a42261724251364bb7a746b6970b4288a45539a33d3b36b114c855b6246a56fee3c61c
2025-05-12 15:53:49 +00:00
yancy 3fbd6fb6b3 test: Add constructor test
The constructor currently has no test coverage.
2025-05-12 08:44:12 -05:00
merge-script 9578ad3e50
Merge rust-bitcoin/rust-bitcoin#4469: Iterate on the script hex APIs
3b8164139f primitives: Add docs section for script hex API (Tobin C. Harding)
6b90e42e78 Finalize the script hex APIs (Tobin C. Harding)

Pull request description:

  In #4316 we made some 'improvements' to what script functions and trait implementations do and do not include the length prefix. Iterate again on it as described here: https://github.com/rust-bitcoin/rust-bitcoin/pull/4316#issuecomment-2847710436

  - Patch 1 does the changes
  - Patch 2 adds some more docs, requires a grammarian to check my Aussie lingua

ACKs for top commit:
  apoelstra:
    ACK 3b8164139f6ecebc97b66a299b4a87c2288d8a76; successfully ran local tests

Tree-SHA512: 481db88ae1b6f5751e81e4cd126f545cfc34bef6dcfcf857f1c7464aeb41f5de95fc4582c015abde04372fe025efa13cdf2906e75517f62cff3ddec05c4d9711
2025-05-12 11:13:50 +00:00
Daniel Roberts d003d48592 Add `Builder::with_capacity()` 2025-05-10 19:20:42 -05:00
yancy b038520c4d Change the return type of effective_value
Prefer the more informative return type NumOpResult over Option.  Also a
returns section was added which describes the different possible
returns.
2025-05-09 17:33:34 -05:00
Tobin C. Harding 6b90e42e78
Finalize the script hex APIs
Recently we made an attempt at making the hex APIs for scripts easier to
use, better documented, and shown via an example.

After that work we decided it would be better if `LowerHex`/`UpperHex`
did not have the prefix. We also wanted to further clarify the inherent
function names to make the all explicit.

See GitHub issue #4316 for the thread of discussion.

Note that this PR does not require changes to the serde regression test
which were non changed in the original work either.
2025-05-08 15:12:05 +10:00
Tobin C. Harding d557caf552
Run the formatter 2025-05-08 10:16:56 +10:00