Commit Graph

5931 Commits

Author SHA1 Message Date
Jamil Lambert, PhD ebab2d9aa7
Update cargo-public-api version
Version 0.42.0 is not compatible with the new version of rust nightly.

Update to v0.43.0
2025-02-04 17:36:26 +00:00
Jamil Lambert, PhD 3b350d4f54
Update to rustc (to nightly-2025-01-31) 2025-02-04 16:54:05 +00:00
Jamil Lambert, PhD 55ab2f34a7
Remove manual implementation of ok
New rustc nightly gives error: manual implementation of `ok`.

Remove it.
2025-02-04 16:47:43 +00:00
Jamil Lambert, PhD 30132c56bb
Fix rustdoc indentation
New nightly lint picked up an incorrect indentation.

Remove extra space.
2025-02-04 16:47:43 +00:00
merge-script 511ac2c47c
Merge rust-bitcoin/rust-bitcoin#4003: Add engine function to `siphash24::Hash`
51cb36881f api: Run just check-api (Tobin C. Harding)
1bcfc80fe7 Add engine function to siphash24::Hash (Tobin C. Harding)

Pull request description:

  The other hashes that require initial state (keys etc) both have an `engine` function on the hash type because they cannot use the `GeneralHash::engine` function.

  Add an `engine` function to the `siphash24::Hash` type.

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

Tree-SHA512: 5cafa5b717235e94167b98a7ff675c3bde5071e736cdc4515ae534b517a5a96eead2bebd25b5dc0123e5e8615bb191c6990ae1ea7dea59b1b58d72547514b5b5
2025-02-03 23:25:45 +00:00
Tobin C. Harding 51cb36881f
api: Run just check-api 2025-02-03 14:10:28 +11:00
Tobin C. Harding 1bcfc80fe7
Add engine function to siphash24::Hash
The other hashes that require initial state (keys etc) both have an
`engine` function on the hash type because they cannot use the
`GeneralHash::engine` function.

Add an `engine` function to the `siphash24::Hash` type.
2025-02-03 13:45:11 +11:00
merge-script f81d10b2b6
Merge rust-bitcoin/rust-bitcoin#3996: Automated nightly rustfmt (2025-02-02)
282bc14d6e 2025-02-02 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 282bc14d6e38ec78b0df01b1169b7ed42a2265cf; successfully ran local tests
  tcharding:
    ACK 282bc14d6e

Tree-SHA512: 88771b5ed72cd357e1bf0bd12d2bbe12b2bb469e667172c8ab4d7beeab46df2270471a586e9b10d7296ef62fc92f7932e4fa7da5905136a7055d42902d580ee2
2025-02-02 23:48:53 +00:00
merge-script 917149998b
Merge rust-bitcoin/rust-bitcoin#3983: Add symmetrical fee calculation method to Weight
e91cb3ff70 Run just check-api (jrakibi)
134c146748 Add Weight::checked_mul_by_fee_rate method (jrakibi)

Pull request description:

  Following up on #3736, this PR adds `checked_mul_by_fee_rate` to `Weight` to mirror the existing `checked_mul_by_weight` method on `FeeRate`.

  This makes the fee calculation more symmetrical.

  Changes:
  - Add `Weight::checked_mul_by_fee_rate` method
  - Add corresponding test cases

  The new method allows users to calculate fees starting from either Weight or FeeRate. This makes fee calculations more intuitive regardless of which type the user starts with.

  Closes #3766

ACKs for top commit:
  tcharding:
    ACK e91cb3ff70
  apoelstra:
    ACK e91cb3ff7078277f5b173773263863fcaef47ae3; successfully ran local tests

Tree-SHA512: 10d17763a8b04027e0f650a8fb15245671214e46ae13fe0b0a86c2ee8b79c1542e449cb298bf65f2e30b6837de5ae237b221b9c90575a0318959feb64ab95221
2025-02-02 23:05:06 +00:00
merge-script 6ba756b246
Merge rust-bitcoin/rust-bitcoin#3993: Automated weekly update to cargo-semver-checks (to 0.39.0)
76bc22b496 Automated update to Github CI to cargo-semver-checks version-0.39.0 (Update cargo-semver-checks Bot)

Pull request description:

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

ACKs for top commit:
  tcharding:
    ACK 76bc22b496

Tree-SHA512: 80846a83085b946293feb08817584bb0a8259ee2cb5c5eb2747eb0e5b482228db888ca3bf64ef48ef0a23d180315df84db9e6e8ecf7700ed2cf2a1f49da22c2a
2025-02-03 08:00:07 +11:00
merge-script 4e355b3843
Merge rust-bitcoin/rust-bitcoin#3987: primitives: Add `script` tests
12a1c3c4b7 Add `script` tests (Jamil Lambert, PhD)

Pull request description:

  Together with #3971 this fixes all of the mutants in `primitives/src/script` except for those related to `serde`.

ACKs for top commit:
  tcharding:
    ACK 12a1c3c4b7
  apoelstra:
    ACK 12a1c3c4b7bc097553fbfb05a0e92320ae42975c; successfully ran local tests
  Kixunil:
    ACK 12a1c3c4b7

Tree-SHA512: c0b757ae672999799e105befb6a2907b8cecb54c3e6d86dbf3e877ddf54e6fd102ebb2604381d0fa89bce0b3b4f70db6cb9ed3b5c85076e13de8369e81431926
2025-02-02 20:58:10 +00:00
merge-script 4700fe7fb2
Merge rust-bitcoin/rust-bitcoin#3982: hashes: Move from_engine functions
b98c489066 hashes: Move from_engine functions (Tobin C. Harding)

Pull request description:

  In order to use the `general_hash_type` macro the must exist a standalone `from_engine` function. Currently this function is in different places in different modules. In an effort to make the `hashes` code easier to reason about put the functions right below the macro.

  Code move only, no other changes.

ACKs for top commit:
  Kixunil:
    ACK b98c489066
  apoelstra:
    ACK b98c489066e8916a383099e5037e5a24832548ba; successfully ran local tests

Tree-SHA512: 8dfbf2b422d078d687708fa94a478ca597fae141f5c1f0a318a36152ca33f4760bb0545ab67523c558a8c3b8d258356975c5e357600d0ac980d473250a2af20e
2025-02-02 03:19:45 +00:00
Fmt Bot 282bc14d6e 2025-02-02 automated rustfmt nightly 2025-02-02 01:18:01 +00:00
merge-script 5ac27b91a1
Merge rust-bitcoin/rust-bitcoin#3984: Fix spelling of `invalid_legcay_address_length`
5fd80581eb Fix spelling of `invalid_legcay_address_length` (Peter Todd)

Pull request description:

  Incorrect spelling kept as a deprecated, hidden, function.

ACKs for top commit:
  tcharding:
    ACK 5fd80581eb
  Kixunil:
    ACK 5fd80581eb
  apoelstra:
    ACK 5fd80581eb9167195bbb4552fbd2210c40b22b7b; successfully ran local tests

Tree-SHA512: 697685a04046a90a22ba0181a64698294d7fb08918c960b707e0087864a36cf00768d7205e452becff7084a87a655d6226b7ddd0c8aa08b4bec71d23399a7f5d
2025-02-01 11:44:57 +00:00
Update cargo-semver-checks Bot 76bc22b496 Automated update to Github CI to cargo-semver-checks version-0.39.0 2025-02-01 01:07:54 +00:00
merge-script bc1e3c0bfc
Merge rust-bitcoin/rust-bitcoin#3968: Add `LockTime` examples
c16eab7723 Add examples to `absolute::LockTime` (Jamil Lambert, PhD)
2d73746ad1 Improve `from_consensus` example (Jamil Lambert, PhD)
25a6742573 Add examples to `relative::LockTime` (Jamil Lambert, PhD)

Pull request description:

  To conform to API guidelines add examples to both `relative` and `absolute` `LockTime`.

  As discussed in #3967 add an example that doesn't round trip in `relative::LockTime::from_consensus`.

ACKs for top commit:
  tcharding:
    ACK c16eab7723
  apoelstra:
    ACK c16eab772375a0b8f82789a3453f7e983523fd50; successfully ran local tests

Tree-SHA512: 898db2dbcccfc54971c65bb72030505dbcfffb035aa74eb376cc1eb8d3619c205338899a58fb9f267fca192c11e7ae48fc17a2d9019c5ff4bd34bf029fa9a48f
2025-01-31 23:37:40 +00:00
merge-script 4ae1b8f0fb
Merge rust-bitcoin/rust-bitcoin#3990: Automated weekly update to rustc stable (to 1.84.1)
390cc39d07 Automated update to Github CI to rustc stable-1.84.1 (Update Stable Rustc Bot)

Pull request description:

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

ACKs for top commit:
  tcharding:
    ACK 390cc39d07

Tree-SHA512: 9fd472e0e7bd1a2d805b1a0b08108223605708724b68659e24149b5049e3a62fec10de49fe684e363b208ccebe662f7221c2fb321eff3cf00dfd34efcdee8e86
2025-02-01 08:28:53 +11:00
merge-script e45bc0056c
Merge rust-bitcoin/rust-bitcoin#3981: Do not implement `Default` for `HmacEngine`
18619a6d0b api: Run just check-api (Tobin C. Harding)
1eb8f1f9e0 Add a Hmac::engine function (Tobin C. Harding)
c352d376ed Do not implement Default for HmacEngine (Tobin C. Harding)

Pull request description:

  The `HmacEngine` should be created using a key. Currently we are providing a `Default` impl that uses `&[]` as the key. This is, I believe, a hangover from when we had a `Default` trait bound somewhere else. It is incorrect and an API footgun - remove it.

  Note this PR includes changes to the bench code in `hmac` that highlights the footgun - pity the poor user we even shot ourselves.

  Patch 2 adds a constructor `Hmac::engine` and uses it in the bench code.

ACKs for top commit:
  Kixunil:
    ACK 18619a6d0b
  apoelstra:
    ACK 18619a6d0b0bca7b7e3603e260b254b4aae6cebf; successfully ran local tests

Tree-SHA512: c96640e7ffba52d5b13b76a6dd9e1381788efcf56ee76300c5111541466bab8018d2546bcecf237c42dbd82e9372a0e43e1ecec37147508e879365d92a4c1451
2025-01-31 20:29:55 +00:00
merge-script 39e9accb0f
Merge rust-bitcoin/rust-bitcoin#3978: Delete `TxOut::NULL`
53bcdefba5 api: Run just check-api (Tobin C. Harding)
dd2df2bf10 Delete `TxOut::NULL` (Martin Habovstiak)
a9ffb1571c Stop using `TxOut::NULL` in tests (Martin Habovstiak)
313406d6ab Optimize `encode_signing_data_to_inner` (Martin Habovstiak)

Pull request description:

  This removes `TxOut::NULL` from our API and replaces the very few occurrences in our code. The PR has three commits so that the first one provably doesn't break anything, and the second one could be dropped if anyone complains about not deprecating but I really hope that won't happen.

  As a side effect this also improves signing performance.

  Closes #3975

ACKs for top commit:
  tcharding:
    ACK 53bcdefba5
  apoelstra:
    ACK 53bcdefba5f60878cc7049d6e157e21e985bb72c; successfully ran local tests; thanks!! No need to deprecate. Nobody was using this thing except maybe as a test dummy value

Tree-SHA512: c603512c2df6b43f6bbc107e5a40f64fa6a5f48a96e192cf2304179e3fd76925a8b3c5f03cd64f4c684ee086fd6abdcebfcf9e5785f0c95b5df9b173f8050e7a
2025-01-31 14:36:12 +00:00
merge-script d491af2ce5
Merge rust-bitcoin/rust-bitcoin#3960: Do not implement Default for `sha25t::Hash<T>`
5134025180 api: Run just check-api (Tobin C. Harding)
9b81a8a2ed hashes: Remove sha256t::Hash Default impl (Tobin C. Harding)

Pull request description:

  The other hash types do not implement Default but the tagged one does still - bad bitcoin devs, no biscuit.

ACKs for top commit:
  Kixunil:
    ACK 5134025180
  apoelstra:
    ACK 513402518016bde0d55ec66f8be573bd3e6209ee; successfully ran local tests

Tree-SHA512: 15a98a42e4e06b9d66c1c07a6eda7d013026700e227b6664a462a035c3ffae0ca034d8b0bfd2a94aecd28f2fb73bfead8f88e29934e6d571e93b385e09f05236
2025-01-31 13:34:19 +00:00
Update Stable Rustc Bot 390cc39d07 Automated update to Github CI to rustc stable-1.84.1 2025-01-31 00:54:42 +00:00
Tobin C. Harding 18619a6d0b
api: Run just check-api 2025-01-31 11:17:01 +11:00
Tobin C. Harding 1eb8f1f9e0
Add a Hmac::engine function
The `HmacEngine` cannot be constructed by way of the `GeneralHash` trait
method because it requires a key. However we can still add an inherent
function to the type to construct an engine.

Add the engine constructor and use it in bench code.
2025-01-31 11:15:42 +11:00
jrakibi e91cb3ff70 Run just check-api 2025-01-31 02:15:23 +03:00
jrakibi 134c146748 Add Weight::checked_mul_by_fee_rate method
Mirror FeeRate::checked_mul_by_weight functionality by adding a symmetrical method to Weight.
This allows users to calculate fees starting from either Weight or FeeRate with consistent behavior.
2025-01-31 02:13:43 +03:00
Tobin C. Harding c352d376ed
Do not implement Default for HmacEngine
The `HmacEngine` should be created using a key. Currently we are
providing a `Default` impl that uses `&[]` as the key. This is, I
believe, a hangover from when we had a `Default` trait bound somewhere
else. It is incorrect and an API footgun - remove it.
2025-01-31 09:58:06 +11:00
Jamil Lambert, PhD 12a1c3c4b7
Add `script` tests
Add tests to kill all the mutants found by `cargo mutants` in `scripts`,
except for those related to `serde`.
2025-01-30 21:46:11 +00:00
Tobin C. Harding 53bcdefba5 api: Run just check-api 2025-01-30 08:17:15 +01:00
Peter Todd 5fd80581eb
Fix spelling of `invalid_legcay_address_length`
Incorrect spelling kept as a deprecated, hidden, function.
2025-01-30 02:37:59 +00:00
Tobin C. Harding b98c489066
hashes: Move from_engine functions
In order to use the `general_hash_type` macro the must exist a
standalone `from_engine` function. Currently this function is in
different places in different modules. In an effort to make the `hashes`
code easier to reason about put the functions right below the macro.

Code move only, no other changes.
2025-01-30 10:51:08 +11:00
Martin Habovstiak dd2df2bf10 Delete `TxOut::NULL`
We've stopped using `TxOut::NULL` in the code and we want to restrict
`Amount` to 21M BTC, so we are now deleting this constant without
deprecation. Deprecation can be backported if needed.
2025-01-29 23:02:51 +01:00
Martin Habovstiak a9ffb1571c Stop using `TxOut::NULL` in tests
We want to get rid of this constant, so we replace it in tests with 0
amount, empty script. Notably, the tests were already using it as a
dummy value - the exact amount was irrelevant, so this change doesn't
break anything.
2025-01-29 23:02:41 +01:00
Martin Habovstiak 313406d6ab Optimize `encode_signing_data_to_inner`
The `encode_signing_data_to_inner` function previously constructed a
transaction internally, requiring a bunch of allocations, which it'd
then consensus-serialize into a writer (hasher). It also used a dummy
`TxOut::NULL` value which we want to get rid of.

To get rid of both allocations and the NULL value we serialize the
transaction on-the-fly. Because the encoding doesn't involve witnesses
it's not too complicated and the consensus encoding will never change so
there are no desync bugs possible. We may later change this to an
abstract transaction though.
2025-01-29 22:51:40 +01:00
merge-script 98db7bca74
Merge rust-bitcoin/rust-bitcoin#3971: primitives: Add tests to `script::borrowed` and `script::owned`
6cde537d9b Add `ScriptBuf` tests (Jamil Lambert, PhD)
566a6e5da6 Add `Script` tests (Jamil Lambert, PhD)

Pull request description:

  Add tests to both `primitives/src/script/borrowed.rs` and `primitives/src/script/owned.rs` to kill the mutants found by running `cargo mutants`.

ACKs for top commit:
  tcharding:
    ACK 6cde537d9b
  apoelstra:
    ACK 6cde537d9ba9bd56495ca47afb3f9a560e9b4358; successfully ran local tests
  Kixunil:
    ACK 6cde537d9b

Tree-SHA512: fc36c1e9249753ebcb0f72e8195c85a7eccd3a0b8b3e4e753102d405494e1f72cd1cdfb6f12af41a9aa6f2ff10142b95827039fa428997b96510a5e262007b25
2025-01-29 19:20:33 +00:00
Jamil Lambert, PhD c16eab7723
Add examples to `absolute::LockTime` 2025-01-29 16:07:49 +00:00
Jamil Lambert, PhD 2d73746ad1
Improve `from_consensus` example
The existing example at first look seemed to contradict the doc above
that the function would not round trip.

Update the example to show the useage for both a time and height based
lock time.

Replace unwrap() with ?
2025-01-29 16:07:49 +00:00
Jamil Lambert, PhD 25a6742573
Add examples to `relative::LockTime` 2025-01-29 16:07:35 +00:00
Tobin C. Harding 5134025180
api: Run just check-api 2025-01-29 12:28:24 +11:00
Tobin C. Harding 9b81a8a2ed
hashes: Remove sha256t::Hash Default impl
The other hash types do not implement `Default` but the tagged one does
still - bad bitcoin devs, no biscuit.
2025-01-29 12:27:48 +11:00
Jamil Lambert, PhD 6cde537d9b
Add `ScriptBuf` tests
Add tests to `owned` to kill the mutants found by `cargo mutants`.
2025-01-28 20:31:17 +00:00
Jamil Lambert, PhD 566a6e5da6
Add `Script` tests
Add tests to `borrowed` to kill the mutants found by `cargo mutants`.
Tests for `to_bytes` were not added since it is deprecated.
2025-01-28 20:30:31 +00:00
merge-script 28b867d8de
Merge rust-bitcoin/rust-bitcoin#3966: Change `#[must_use]` to be the same as stdlib
cb5ffde9ee Change `#[must_use]` to be the same as stdlib (Jamil Lambert, PhD)

Pull request description:

  Change the iterator `#[must_use]` message to be the same as stdlib uses.

  Message taken from https://doc.rust-lang.org/src/core/iter/traits/iterator.rs.html#38

  Close #3962

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

Tree-SHA512: 4866d9bddccdc28e2ba2b15cb4041851abb1512cea0317f20d2e2306df6dcd1addb828d61a84a2083d3ef47abb5cf9276e857cf098de2d28b4706ecd0a1f24fa
2025-01-28 16:53:58 +00:00
merge-script b99a81a0fe
Merge rust-bitcoin/rust-bitcoin#3955: Refactor `LockTime` tests
bc8a378187 Rename `day_` variables to `time_` (Jamil Lambert, PhD)
922392268f Combine satisfied by into singe tests (Jamil Lambert, PhD)
33a7a35bbb Make naming consistent in tests (Jamil Lambert, PhD)

Pull request description:

  As mentioned in https://github.com/rust-bitcoin/rust-bitcoin/pull/3948#discussion_r1927690822 the variable naming in the tests in both `relative::LockTime` and `absolute::LockTime` is inconsistent and possibly confusing.

  Make variable names consistent.

  In `absolute::LockTime` incorporate the two standalone tests `satisfied_by_same` into `satisfied_by` to simplify the tests and conform to what is done in `relative::LockTime` .

ACKs for top commit:
  tcharding:
    ACK bc8a378187
  apoelstra:
    ACK bc8a378187b9fade96223c8ae9578b78f941f449; successfully ran local tests

Tree-SHA512: 643498e05a9fce16d2880c1fdd39422e239bfc60b959d9207d704e9d1de7bc6508761da602bc53217b74c8b7f1986f6d5a0f769507918235ddba72d5f77ca15f
2025-01-28 13:37:01 +00:00
merge-script 21a4b7a3db
Merge rust-bitcoin/rust-bitcoin#3954: Update `README.md`
fe09896c7d Update `README.md` (Jamil Lambert, PhD)

Pull request description:

  `.github/workflows/README.md` is stale

  Add the new `API` check and reorder jobs to match `rust.yml`.

  Close #3942

ACKs for top commit:
  Kixunil:
    ACK fe09896c7d
  tcharding:
    ACK fe09896c7d
  apoelstra:
    ACK fe09896c7d87a0ae6a1b6d6c2525bd5fdff4f3ea; successfully ran local tests

Tree-SHA512: bbd9c57f20022a1383541ce574adc2db3cf02994b71749543ad080ecb585fae7c3577a4d832351948f749edebb5525da50ff79ba6354e1510e83081ba36481f3
2025-01-28 04:07:27 +00:00
Jamil Lambert, PhD cb5ffde9ee
Change `#[must_use]` to be the same as stdlib 2025-01-27 20:13:29 +00:00
Jamil Lambert, PhD fe09896c7d
Update `README.md`
`.github/workflows/README.md` is stale

Add the new `API`
check and reorder jobs to match `rust.yaml`.
2025-01-27 16:59:40 +00:00
Jamil Lambert, PhD bc8a378187
Rename `day_` variables to `time_`
To be consistent with similar lock height test function rename
`day_after/before` to `time_after/before` and change the same `time` to
`time_same`.
2025-01-27 16:45:24 +00:00
Jamil Lambert, PhD 922392268f
Combine satisfied by into singe tests
Include the satisfied by same time/height into the previous test that
checks above and below.
2025-01-27 16:44:41 +00:00
Jamil Lambert, PhD 33a7a35bbb
Make naming consistent in tests
Rename all occurrences of LockTime to specify if it is by height or
time.
2025-01-27 16:42:45 +00:00
merge-script 9c15a31559
Merge rust-bitcoin/rust-bitcoin#3957: Automated daily update to rustc (to nightly-2025-01-24)
75303b331e Automated update to Github CI to rustc nightly-2025-01-24 (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 75303b331e

Tree-SHA512: 81cd6635d412697256c01a6b149631b02555847ceda359823ae20dd78393c9e9d129bc29ceba3e95c4c9e0af4a874419e148db13b828d81f7ae89282327ca41a
2025-01-27 11:22:35 +11:00