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
71fab82a1b io: Improve docs on macro (Tobin C. Harding)
9c81d5e747 io: Move macro_export below docs (Tobin C. Harding)
b109177e11 io: Improve rustdocs (Tobin C. Harding)
07d8703a00 io: Add SPDX identifier (Tobin C. Harding)
b844637935 io: Remove rustdoc for private module (Tobin C. Harding)
Pull request description:
As part of #3643 improve the public documentation on the `io` crate.
While doing this I also checked:
- C-FAILURE
- C-LINK
- C-METADATA
- C-RELNOTES
- C-HIDDEN
ACKs for top commit:
apoelstra:
ACK 71fab82a1b32e6077adb896be9d8ac12d5513e0a; successfully ran local tests
Tree-SHA512: 91b8807102277fb7f6602837b7d0e64e4276c9c5bf748ab875ea0e4f1f7f91bc989413acd25e4412d72d6f3744a22b746ed63cbac20d9b42217cd3164c7e6847
5f75bfaa63 Improve examples on Denomination (Tobin C. Harding)
Pull request description:
Reduce the noise in the examples.
ACKs for top commit:
apoelstra:
ACK 5f75bfaa63309c7526136d430ca8092197ab7c8e; successfully ran local tests; yeah, agreed, this is nicer to read
Tree-SHA512: 01c5863f8712a8ca3b38d3f96be9d08078ca28d8cfc3dd8e8528c388e5f82406a0d43def552b7b53f034c9bf440f7d2d0fec6a760cf69a245b109d0ce4e288c3
4dad4730a8 Add unreleased changelog entry (Tobin C. Harding)
08bb57e499 Use MAX_MONEY in serde regression test (Tobin C. Harding)
Pull request description:
We plan on enforcing MAX_MONEY in the amount types. In preparation use MAX_MONEY in the serde regression test instead of the arbitrary, and too large DEADBEEFCAFEBABE value.
ACKs for top commit:
apoelstra:
ACK 4dad4730a81f9f08a565f196e5699f054e28f977; successfully ran local tests
Tree-SHA512: 10fefdb75289f4c93537e031410eb729420729563b262d6104948a0176a78c4f6130956b550cc08ffc924b1bce1c42f0544542879a4d44165022196ef695718a
13a3f490b8 Use Self instead of amount type (Tobin C. Harding)
34e3049ae0 Use sats instead of satoshi (Tobin C. Harding)
00b71a670f Use from_sat_unchecked for hardcoded ints (Tobin C. Harding)
8fdec67f7d Change local var ua to sat (Tobin C. Harding)
c6f056672b Change local var sa to ssat (Tobin C. Harding)
f3e853e07a units: Do trivial refactor of amount::tests (Tobin C. Harding)
dbec9807f9 Shorten identifiers by removing _in_sats (Tobin C. Harding)
154a4420fc Stop using FQP on Amount type (Tobin C. Harding)
8e16a48252 Run the formatter (Tobin C. Harding)
Pull request description:
Do a bunch of refactorings to tease out changes from #3794.
The first 8 are uncontroversial. The 9th one is subjective. The last one is unusual but IMO worth doing because of the relationship between the two amount modules.
Do note that this PR is 100% internal changes - please please don't bike shed this to death.
ACKs for top commit:
apoelstra:
ACK 13a3f490b80e4c8f8e1753111a914315eefd73e6; successfully ran local tests; lgtm
Tree-SHA512: e2ef0e7fbdaaf632a9840920a227a901fbeb55a29398013cd6cb764b1ff7c0a7c5a1648fd8f606e8b5f7523943886f5eff54cf4054d24349feb72f0b4de05b91
I claim that if the two amount modules are coded as similarly as
possible it will be easier to ensure that we have the API's uniform and
bug free. To make auditing the modules easier and less error prone use
`Self` instead of the explicit type. This makes it easier to see
differences in the modules and to ensure the differences are correct and
required.
Internal change, no logic changes whatsoever.
420e8c043e Fix mutants in units (Jamil Lambert, PhD)
Pull request description:
Cargo mutant found missed mutants in the bitcoin constants in both signed and unsigned amounts.
Add a test to check their values.
ACKs for top commit:
tcharding:
ACK 420e8c043e
apoelstra:
ACK 420e8c043e34817fa51939c0484ed77cb972ad46; successfully ran local tests; sure, this is reasonable enough
Tree-SHA512: 7a3834b9ac8a6c4742405d67e7a5d5b4eecdb6ec262d7525ba9538201c84fd4aef1a900c43a7dfc041cc09741dfc6fa34e7664ae371b66e9554718af0a85083b
We plan on enforcing MAX_MONEY in the amount types. In preparation use
MAX_MONEY in the serde regression test instead of the arbitrary, and too
large DEADBEEFCAFEBABE value.
We have an `_unchecked` amount constructor that makes no assumptions
about the argument. We would like to start enforcing MAX_MONEY but the
diff to introduce this is massive. In an effort to make it smaller we
can do all the hardcoded ints first. We did this already but a bunch
more snuck in or were missed.
In any amount constructor that passes in a hardcoded const as a decimal
integer (i.e., not hex) use the `_unchecked` version.
Done in preparation for enforcing MAX_MONEY.
4dcdf73cfa Add `µBTC` and `µbtc` to tests (Jamil Lambert, PhD)
afba28e188 Change `uBTC` to `µBTC` in rustdocs (Jamil Lambert, PhD)
2ca24f00f2 Add `µBTC` as a recognized `str` form of `uBTC` (Jamil Lambert, PhD)
Pull request description:
`µ` is the correct letter for the SI unit micro but is not on most standard keyboards. `u` was used instead because it looks similar.
Add `µBTC` to the list of recognized strings for MicroBitcoin. This is an addition only, `uBTC` still works as normal.
Change `uBTC` to `µBTC` in the rustdocs. The examples have been left as `uBTC` since this is easier for most people to use.
Add `µBTC` and `µbtc` to the tests.
Close#3941
ACKs for top commit:
apoelstra:
ACK 4dcdf73cfa896b2c095cda9064c6e0a0e9aeec2b; successfully ran local tests
storopoli:
ACK 4dcdf73cfa
tcharding:
ACK 4dcdf73cfa
Tree-SHA512: 0f6e8b8b9c04f1a4dc6536c0420b2ded568ab96d2301b7d488807cb26003b91a787a6cf9023705c731682580f73ae5247f3f3b1e8646e4eb720c5a65da582933
6d0c6c61ef Run just check-api (Jamil Lambert, PhD)
20d3f16a54 Fix clippy lint in new rustc nightly (Jamil Lambert, PhD)
Pull request description:
Automated update #3922 failed due to a new clippy lint and a change in the `cargo-public-api` format.
Update nightly to 2025-01-16, fix the clippy lint and run `just check-api`.
ACKs for top commit:
tcharding:
ACK 6d0c6c61ef
apoelstra:
ACK 6d0c6c61ef759ac4bfc3b16d32e93f1b483b9365; successfully ran local tests
Tree-SHA512: a4fb8c3dd253acc0d587399771d4ce7893fc5e16cd9637c4968fd730e101456ecaad786506dc83a3d8447b1ac35617ec649d0af2ca52f1d7deb79b04c5366b56
bfba2a85dd Kill remaining mutants (Shing Him Ng)
871fa08f61 Fix typo in serde docs (Shing Him Ng)
462c7a1130 Add weekly cargo-mutants workflow (Shing Him Ng)
Pull request description:
This PR introduces `cargo-mutants` via a Github weekly workflow, similar to how the formatter job runs. It can also be updated to run against [incremental changes in a PR](https://mutants.rs/pr-diff.html) or to create an issues that list the new mutants. To address #3796, I've configured it to only run in `units` for now since that's nearing 1.0.
Here's a [sample run](https://github.com/shinghim/rust-bitcoin/actions/runs/12457984710) i did in my fork, if anyone would like to see what's in the `mutants-out` artifact that gets generated.
ACKs for top commit:
tcharding:
ACK bfba2a85dd
apoelstra:
ACK bfba2a85ddaad6b366a7502cbda1ff2462dfd4c7; successfully ran local tests
Tree-SHA512: e4a44b6f5121e4238c1c3576616f551f4f43349cf5fd5ac1d6331f958a4458753a55519bdafc16965cb2e67201ef6c91b188c79ffcc222f780c421df9a701063
7482fcd934 Run just check-api (jrakibi)
bcc38c40e0 Add Amount division by FeeRate (jrakibi)
Pull request description:
Add checked_div_by_fee_rate method to Amount that computes the maximum weight for a transaction with a given fee rate. This complements the existing `fee = fee_rate * weight `and `fee_rate = fee / weight` operations
- Add `checked_div_by_fee_rate` method that returns Option<Weight>
- Implement` Div<FeeRate>` for Amount for operator syntax support
- Use `floor` division to ensure weight doesn't exceed intended fee
This allows calculating the maximum transaction weight possible for a given fee amount and fee rate.
Closes#3814
ACKs for top commit:
apoelstra:
ACK 7482fcd934c09e3cd6cd25fd4328960b02f8e976; successfully ran local tests
tcharding:
ACK 7482fcd934
Tree-SHA512: 622ca42bde1f67782a3c2996efcba0132fedb5e984f594603aece974de6acdeb4b22d63239d29d46fb8623c8082841c33b1d5b9ad2ea51e2f63e6f5d859daa7e
`µ` is the correct letter for the SI unit micro but is not on most
standard keyboards. `u` was used instead because it looks similar.
Add `µBTC` to the list of recognized strings for MicroBitcoin and to the
rustdocs.
New nightly lint warning "called `Iterator::last` on a
`DoubleEndedIterator`; this will needlessly iterate the entire iterator"
Code that gives the warning is correct, allow the lint to remove the
warning.
Update rustc nightly to 2025-01-16
11a9dced76 api: Run just check-api (Tobin C. Harding)
31dda6d53d Make io::Error Sync (Tobin C. Harding)
Pull request description:
Currently we use a marker that contains an `UnsafeCell` but `UnsafeCell` is not `Sync` so this makes `io::Error` not `Sync`. We can instead wrap the `UnsafeCell` and implement `Sync` for it.
Fix: #3883
ACKs for top commit:
apoelstra:
ACK 11a9dced766c56d6258af6f43d8691aaf7b2110f; successfully ran local tests
Tree-SHA512: 77c89a32e6d409be9db3a40573b78f69eadf24f2d6d4739510753e339ba30a5e6082d21fef52b44481ff2b60f49c1b31dfe45fa12299f97176ba48853b9487a6
7277092af4 Remove mutagen (Tobin C. Harding)
Pull request description:
Back in 2022 we elected to use `mutagen` for mutation testing. Since then `cargo mutants` has progressed to a point where we would now like to use it instead.
Remove all the `mutagen` stuff.
Close: #2829
ACKs for top commit:
ndungudedan:
tested ACK [7277092](7277092af4)
apoelstra:
ACK 7277092af44f44f59bdb6326561b0b47416cc085; successfully ran local tests
Tree-SHA512: bf271bbb30607cfc9970ed6b62e1671279517d6c14c165f063b1fcbef61f735916b1510cd2c10ff624bb8d031cb2783f9636bd7db4dadb6f7534e17db25cfcf2
81d4c2e067 Remove unnecessary doc(hidden) (Tobin C. Harding)
Pull request description:
This trait is private and is meant just for sealing. It already will not show up in public docs and cannot be used by downstream users.
Resolve: #3912
ACKs for top commit:
jamillambert:
ACK 81d4c2e067
apoelstra:
ACK 81d4c2e067ec7ed1d39372783261704cb1e802d8; successfully ran local tests
Tree-SHA512: 55668b9013c76364fb4ff37d47502b87c38868d0113cab639415f70d93e99221c0df08e27bf9514390cd9e365cf27baa2bf0727877a694a3b078de7edc123023
Implement `checked_div_by_fee_rate_floor` and `checked_div_by_fee_rate_ceil` methods to compute the maximum and minimum transaction weights.
These methods provide precise weight calculations using both floor and ceiling divisions.
- Introduce `checked_div_by_fee_rate_floor` for floor-based weight division.
- Add `checked_div_by_fee_rate_ceil` for ceiling-based weight division.
- Update `ops::Div` implementation for `Amount` to use floor division by default.
- Include unit tests to validate both floor and ceiling division methods.
7c7fc36784 Improve docs on Denomination (Tobin C. Harding)
Pull request description:
Document what each denomination means.
ACKs for top commit:
jamillambert:
ACK 7c7fc36784
apoelstra:
ACK 7c7fc36784603480df1975f4a77ec583b74efa5c; successfully ran local tests; sure
Tree-SHA512: c0f3a5172e4dfdc6195efc34f36d65700591fe19015e455aa20cacaacc9c516518cec7716028779fd408e8a639eb4a5962a372b1d1d70db06a0ea8130c3bd703
55470f7357 Change `create` to `construct` in rustdocs (Jamil Lambert, PhD)
Pull request description:
In preparation for units 1.0 address #3868 and make sure "constructs" is used instead of "creates" in rustdocs.
ACKs for top commit:
apoelstra:
ACK 55470f73571ce0e0279f5697a252695e8c8df9b5; successfully ran local tests; sure
tcharding:
ACK 55470f7357
Tree-SHA512: 48f9b6cedfca782e698eec4520885f35834582ed098a65b00ccdfa54167c91fe62405f90c9c1e72a671e72ac349af74ac12808ce9e0708799f43d86749590649
7ca5c5ccae Fix rustdoc title on hex_u128_* (Tobin C. Harding)
f1e2564821 Improve docs on parse::int_from_string (Tobin C. Harding)
d97cbc6d27 units: Correct docs on private Sealed trait (Tobin C. Harding)
Pull request description:
Audit the `units::parse` module checking for sanity of the API. Could still possibly do with more improvements to the docs but for the `1.0-alpha` this is good to go IMO.
Close: #3710
ACKs for top commit:
apoelstra:
ACK 7ca5c5ccae1efe5862f21bfc670257837a202517; successfully ran local tests; looks good!
Tree-SHA512: 937e8f6e1ae0a17217b770daffe1968ec9046c86728a360f1297d7027318511fece31440f462fdaeb94c2a69901a970e20bd2599a6d963bfbdf06b25378fe543
289a521426 units: Test for dyn compatibility (Tobin C. Harding)
Pull request description:
Phew! dyn compatibility is a non-trivial concept. There are four public traits in `units`, only one is dyn compatible.
This patch is done in order to check off C-OBJECT from the Rust API guidelines checklist.
Add a test to check the public traits in `units` for dyn compatibility.
While we are at it add a code comment on `Integer` stating why its not dyn-compatible.
ref: https://rust-lang.github.io/api-guidelines/flexibility.html#c-object
ACKs for top commit:
apoelstra:
ACK 289a5214265a1f0d7b320b0121775f868a386c57; successfully ran local tests; nice!
Tree-SHA512: 6f247d4977a87acf68a03bfae12335a8f16ebbe44478da757128f54697c859fa278ddbc0e5c4479918797db91dbe8eef3d2adf60f83518182cb10e84e77120da