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
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
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 and update the lock files.
Close: #2829
e0028239cf api: Run just check-api (Tobin C. Harding)
5eb5941215 Add FIFTY_BTC const to the amount types (Tobin C. Harding)
Pull request description:
The mining reward for the first epoc is 50 bitcoin. For mainnet this is old news but for regtest it is still relevant.
Add and use a new const `FIFTY_BTC` to the `Amount` type. To keep the amount types uniform also add it to the `SignedAmount`.
ACKs for top commit:
storopoli:
ACK e0028239cf
jamillambert:
ACK e0028239cf
apoelstra:
ACK e0028239cf207660deb2873a92bacfa1315af634; successfully ran local tests
Tree-SHA512: 623ed8b1f5fe8dd95309179308fea83d68be4349becf6305769b0378cc9032961df2c062dc2bf702fec5e2394e8abb7360d2be6f19b6cf505db8769a5ae39e16
I only just worked on this function a week ago and already I couldn't
see from reading the code why it exists. Add a paragraph to the rustdocs
to save the next guy the trouble of working it out.
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
f01bb30121 Use sat variable for constructor (Tobin C. Harding)
34f846c074 Use ssat variable for constructor (Tobin C. Harding)
Pull request description:
Add `sat` and `ssat` throughout the `amount::tests` module after new tests were added recently.
ACKs for top commit:
jamillambert:
ACK f01bb30121
apoelstra:
ACK f01bb30121ef5a59af069a55db727ee5a9ba71bb; successfully ran local tests
Tree-SHA512: 6a4cdc47000b22625132fe0d8faa7dbff59acfc0b6b4faffe091f885f8d0fd5f5ce15e2298c87e25bd4cc13a2611cecadb43b7d44ccd768a04cd150223577b6b
0719997fee api: Run just check-api (Tobin C. Harding)
1e503a8d3b Remove deprecated std::error::Error trait method impls (Tobin C. Harding)
Pull request description:
The `description` method was deprecated in Rust `v1.42`. The `cause` method was deprecated in Rust `v1.33`. Our MSRV is now Rust `v1.63`.
We do not need to implement the deprecated functions any longer.
Fix: #3869
ACKs for top commit:
apoelstra:
ACK 0719997feef4ef8b2686e570d4083f88be9c5bb0; successfully ran local tests
Tree-SHA512: e627f614ab8c36ce34109b8d8ef9216e9e802e6db286fa676eff3e6741da39f03cf6080cf47f7d6aa414c5acd790f94b389b219f18992cfcc8869b668e745152
The `description` method was deprecated in Rust `v1.42`. The `cause`
method was deprecated in Rust `v1.33`. Our MSRV is now Rust `v1.63`.
We do not need to implement the deprecated functions any longer.
Fix: #3869
The mining reward for the first epoc is 50 bitcoin. For mainnet this is
old news but for regtest it is still relevant.
Add and use a new const `FIFTY_BTC` to the `Amount` type. To keep the
amount types uniform also add it to the `SignedAmount`.
9ef8e294ac api: Run just check-api (Tobin C. Harding)
3542803c4e Make Cursor methods const (Tobin C. Harding)
Pull request description:
Mirror the `std::io::Cursor` type by making the same methods `const`.
ACKs for top commit:
jamillambert:
ACK 9ef8e294ac
apoelstra:
ACK 9ef8e294ac81c79f413fbe47372a3f94c926ef12; successfully ran local tests
Tree-SHA512: 60ad8169c9bcc90360fcd3c3439256d86af4a77733a00a66e9b155bdb89580d4971efd55a93f1873363ed9d24f0b2b8f5a0da1857bb5aa8a112b13e27239a984
f9be30ddbe units: Fix `missing_errors_doc` clippy lint (Jamil Lambert, PhD)
Pull request description:
Change the `missing_errors_doc` clippy lint to `warn`.
Allow `missing_errors_doc` in `amount/serde.rs` and `fee_rate/serde.rs`. Add missing `# Errors` sections to rustdocs where the lint gives a warning.
One of the TODO lints in Issue https://github.com/rust-bitcoin/rust-bitcoin/issues/3825
ACKs for top commit:
tcharding:
ACK f9be30ddbe
apoelstra:
ACK f9be30ddbe5c0837ab3e408dfadabc6c6cd2068e; successfully ran local tests
Tree-SHA512: 8039804ab86c18dceadb425c8531cd4064431393367c6053249e00386f48998d8d84a3aee6ad139e7e2ca3ac3c94e05ee694d72270bf285f6b90d0ff821e622e
29f1a4613a Enable `ref_option` lint and allow individually (Jamil Lambert, PhD)
Pull request description:
The last `TODO` in #3825
Allow the `ref_option` lint in the cases where the lint wants us to change the API to ```use `Option<&T>` instead of `&Option<T>` ```
The other option would be to keep the lint as `allow` and add a comment to `Cargo.toml` as to why we are allowing it like the other cases that are allowed.
Close#3825
ACKs for top commit:
apoelstra:
ACK 29f1a4613a090cd23baded1ef577aa4e3da8d33f; successfully ran local tests; nice!
tcharding:
ACK 29f1a4613a
Tree-SHA512: 181d617060e8ae0e75f033b1f356106fc89bdee9841085c889b775e82711c147e5282ecb0e3bf80cdb058034365bbfc7289c029ba0bf8b0b0f26d22505c63aa2
b11ace359a Fix up ParsePublickeyError (Innocent Onyemaenu)
Pull request description:
Resolves#3835
In #945fcd09 we forgot to Update impl for ParsePublicKeyError Display and Error traits
ACKs for top commit:
tcharding:
ACK b11ace359a
apoelstra:
ACK b11ace359a52d9137b8fe5919d9825d61e3e9fad; successfully ran local tests; thanks!!
Tree-SHA512: 5c4e5e113605bc5b9c3c0d2ca65a0fdae80726a0f2f791255cc1d6567812a9132ff4f5bd8f30276fef916469d5fd29f6d72ddf4adb6340e52f4e0198ac4fb371
e316e6e719 Fix `missing_panics_doc` clippy lint in units (Jamil Lambert, PhD)
Pull request description:
Change the units `missing_panics_doc` clippy lint to `warn` and allow for the functions that can't panic.
One of the TODO lints in Issue #3825
ACKs for top commit:
tcharding:
ACK e316e6e719
apoelstra:
ACK e316e6e7195993b7dd0e005d2f22f29dfea023c5; successfully ran local tests
Tree-SHA512: 3db74e499dc590a5158869d1a80613d37b3fb09f2d428918dc23b9f1521496d8afff63988f022d6cfd7688d33295f976effe73adbadd8da93dae8fb5d2d13dc5
As we do in other places in the `amount::tests` module; use a local
`sat` variable bound to the `Amount::from_sat` constructor.
Internal change, no logic changes.
As we do in other places in the `amount::tests` module; use a local
`ssat` variable bound to the `SignedAmount::from_sat` constructor.
Internal change, no logic changes.
Change the lint to `warn` in `units/Cargo.toml`.
Allow `missing_errors_doc` in `amount/serde.rs` and `fee_rate/serde.rs`.
Add missing `# Errors` sections to rustdocs where the lint gives a
warning.
In #3847 we added an `InvalidCharError` into one of the variants of
`ParsePublicKeyError` but we forgot to update the trait
implementations.
Fix the `error::Error` and `Display` implementations for
`ParsePublicKeyError`. While we are at it match on `*self` as is
typical in this codebase.
With this applied #3835 is fully resolved.
Close: #3835
56286265a5 api: Run just check-api (Tobin C. Harding)
39523ea1f5 units: Remove InputString from the public API (Tobin C. Harding)
Pull request description:
Currently `InputString` is in the public API of `units` because of the trait bound on `parse::int()`. We can just do the monomorphisisation manually to remove it.
This patch renames `int` to have three different names, one for `&str` one for `String`, and one for `Box<str>` e.g., `units::parse::int_from_str`.
Close#3708
ACKs for top commit:
apoelstra:
ACK 56286265a55368572c61b03bcb81fe04fb7921c0; successfully ran local tests; this looks great!
Tree-SHA512: 5c16640fe4651fbbafd5e3558d8918414df1bb1579ca64b2256f3c10df410481ae29a77ab89f7a1571bfdd710dc6c6bd8ee9217f2c54eeef06e21ab6ce4aa735
Currently `InputString` is in the public API of `units` because of the
trait bound on `parse::int()`. We can just do the monomorphisisation
manually to remove it.
This patch renames `int` to have three different names, one for `&str`
one for `String`, and one for `Box<str>`.