Commit Graph

672 Commits

Author SHA1 Message Date
merge-script fa07198f21
Merge rust-bitcoin/rust-bitcoin#4511: Modify `locktime` `serde` implementations
4621d2bde1 Modify locktime serde implemenations (Tobin C. Harding)
200c276315 bitcoin: Make test code spacing uniform (Tobin C. Harding)

Pull request description:

  Patch 1 is preparatory clean up. Patch 2 is the meat and potatoes. See commit log there for full explanation.

  Briefly:

      - Remove `serde` stuff from `units::locktime`
      - Manually implement `serde` traits on `relative::LockTime`
      - Fix the regression test to use the new format

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

Tree-SHA512: bc96d79dd4d9f5a124c22f0d3be4750cb7b6e86ba448b31e233982567578337d331b2582c6e1f953c00e8393c4a4552c4b574fe8a55323c911115b269b24090e
2025-06-04 17:32:02 +00:00
merge-script a13ba99c11
Merge rust-bitcoin/rust-bitcoin#4534: Make `FeeRate` use MvB internally
56516757ad Add code comment to amount calculation (Tobin C. Harding)
8cf1dc39b5 Fix incorrect code comment (Tobin C. Harding)
7c186e6081 Refactor fee functions (Tobin C. Harding)
bf0776e3dd Remove panic using checked arithmetic (Tobin C. Harding)
b65860067f Make fee functions const (Tobin C. Harding)
9b2fc021b2 Improve rustdocs on FeeRate (Tobin C. Harding)
1bd1e89458 Re-introduce FeeRate encapsulate module (Tobin C. Harding)
b27d8e5819 Change the internal representation of FeeRate (Tobin C. Harding)
2e0b88ba76 bitcoin: Fix dust 'fee' identifiers (Tobin C. Harding)
399bca531c Reduce the FeeRate::MAX value (Tobin C. Harding)
d174c06a4a Saturate to_fee to Amount::MAX (Tobin C. Harding)
64ac33754f Add missing argument docs (Tobin C. Harding)
fe0a448e78 Temporarily remove const from fee calc function (Tobin C. Harding)
b929022d56 Add floor/ceil versions of to_sat_per_kwu (Tobin C. Harding)
64098e4578 Remove encapsulate module from fee rate (Tobin C. Harding)

Pull request description:

  The `FeeRate` is a bit entangled with amount and weight.  Also we have an off-by-one bug caused by rounding errors and the fact that we use kwu internally.

  We can get more precision in the fee rate by internally using per million virtual bytes.

  - Fix: #4516
  - Fix: #4497
  - Fix: #3806

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

Tree-SHA512: 0c6e7e2c9420886d5332e32519838d6ea415d269abda916e51d5847aa2475c87fa4abfc29b5f75e8b10c44df67ae29d823aa93f7cfabbc89eb27f2173b103242
2025-06-04 16:42:55 +00:00
Tobin C. Harding 4621d2bde1
Modify locktime serde implemenations
The `units::locktime` types are used for two things:

- They are the inner types of `primitives` `LockTime`s
- They are used ephemerally for checking satisfaction

Neither of these use cases requires `serde` impls for the `units` types.
Since we are trying to release 1.0 with minimal amounts of code we
should remove them.

For `LockTime`s that need to be stored on disk or go over the wire we
can manually implement the `serde` traits. For `absolute::LockTime` this
is done already and there is no reason the `relative::LockTime` impl
cannot be the same [0]. This differs from the current `serde` trait impls
but we have already decided that in 0.33 we are going to accept breakage
and direct users to use 0.32 to handle it.

- Remove `serde` stuff from `units::locktime`
- Manually implement `serde` traits on `relative::LockTime`
- Fix the regression test to use the new format

While we are at it use a uniform terse call in `serialize`.

[0] This is because there is an unambiguous encoding for the whole set
of locktimes - consensus encoding.
2025-06-01 14:07:33 +01:00
merge-script 6d8299e8b8
Merge rust-bitcoin/rust-bitcoin#4468: Improve lock times - fix off-by-one bug
4ccecf5dec Fix stale Height type link (Tobin C. Harding)
caebb1bf73 units: relative: Do minor rustdocs fixes (Tobin C. Harding)
40bb177bc2 Put is_satisfied_by functions together (Tobin C. Harding)
480a2cd62a Favour new function `from_mtp` over deprecated (Tobin C. Harding)
f9d6453d5b Shorten locktime type term (Tobin C. Harding)
727047bd39 Fix off-by-one-bug in absolute locktime (Tobin C. Harding)
3ffdc54ca5 Fix off-by-one bug in relative locktime (Tobin C. Harding)
a2ff8ddbbb Improve relative::LockTime is_satisfied_by_{height, time} (Tobin C. Harding)

Pull request description:

  Make the APIs uniform in relative and absolute locktimes in relation to the `is_satisfied_by` functions. In doing so improve the API and fix an off-by-one bug when checking satisfaction of locks by height.

  Done in three patches but maybe should be squashed? Probably easiest to review by looking at all the `is_satisfied_by*` functions and convincing yourself we got it right.

  EDIT: Now has 5 cleanup patches also (mostly docs cleanups).

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

Tree-SHA512: 9206cb464a06647510a35a7d564062823117e75df60251969be458616f4f5d04acf0aada53dbf7d493a2a2a72d26b3a300417a6499e45413d5f2a011538b7826
2025-05-31 15:48:29 +00:00
Tobin C. Harding 7c186e6081
Refactor fee functions
The `fee` functions are a bit convoluted because of the usage of
`const`. Refactor a couple of them to be easier to read.

Internal change only.
2025-05-31 07:52:35 +01:00
Tobin C. Harding bf0776e3dd
Remove panic using checked arithmetic
During dev I introduced a pancic, remove it.
2025-05-31 07:52:35 +01:00
Tobin C. Harding b65860067f
Make fee functions const
We temporarily removed `const` in the `fee` module to make patching and
reviewing easier. Now add it back in.
2025-05-31 07:52:35 +01:00
Tobin C. Harding 9b2fc021b2
Improve rustdocs on FeeRate
Remove the unit from associated consts and then make all the rustdocs on
the various consts use 'The'.
2025-05-31 07:52:34 +01:00
Tobin C. Harding 1bd1e89458
Re-introduce FeeRate encapsulate module
Now we have the `fee_rate` module clened up re-introduce the
`encapsulate` module using MvB.
2025-05-31 07:52:34 +01:00
Tobin C. Harding b27d8e5819
Change the internal representation of FeeRate
To get more precision use sats per million virtual bytes.

To make review easier keep most calls in tests using
`FeeRate::from_sats_per_kwu` and just unwrap. These can likely be
cleaned up later on if we want to.

For `serde` just change the module to `_floor` and leave it at that. The
serde stuff likely needs re-visiting before release anyways.
2025-05-31 07:52:31 +01:00
Tobin C. Harding 2e0b88ba76
bitcoin: Fix dust 'fee' identifiers
Currently we get the fee_rate per kwu then multiply it by 4. Instead
lets add a per_kvb function to `FeeRate`. We are about to change the
internal representation of `FeeRate` to use MvB so for now just panic on
ovelflow.

Also these are fee _rates_ - we already have suboptimal names from Core
in the consts in `policy`, no need to let them infect other identifiers.
2025-05-31 07:52:01 +01:00
Tobin C. Harding 399bca531c
Reduce the FeeRate::MAX value
In preparation for changing the internal representation of `FeeRate` to
use MvB reduce the max value by 4_000.

Done separately to make the change explicit.
2025-05-31 07:52:00 +01:00
Tobin C. Harding d174c06a4a
Saturate to_fee to Amount::MAX
The `FeeRate::checked_mul_by_weight` function currently returns a
`NumOpResult` but all other `checked_` functions return an `Option`.
This is surprising and adds no additional information.

Change `checked_mul_by_weight` to return `None` on overflow. But in
`to_fee` saturate to `Amount::MAX` because doing so makes a few APIs
better without any risk since a fee must be checked anyway so
`Amount::MAX` as a fee is equally descriptive in the error case.

This leads to removing the `NumOpResult` from `effective_value` also.

Note that sadly we remove the very nice docs on `NumOpResult::map`
because they no longer work.

Fix: #4497
2025-05-31 07:52:00 +01:00
Tobin C. Harding fe0a448e78
Temporarily remove const from fee calc function
Code that works with `const` is annoying to use and hard to reason
about. Just remove all the consts for now so we can hack on `FeeRate`.

Introduces two lint warnings about manual implementation of `map` but
they will go away later.
2025-05-31 07:51:59 +01:00
Tobin C. Harding b929022d56
Add floor/ceil versions of to_sat_per_kwu
In preparation for changing the inner representation of `FeeRate` add
floor and ceil versions of the getter function `to_sat_per_kwu`.

For now both functions return the same thing but still call the
correct one so that when we change the representation we do not need
to re-visit them.
2025-05-31 07:51:59 +01:00
Tobin C. Harding 64098e4578
Remove encapsulate module from fee rate
This module is a PITA to work on, just remove it until the dust settles
on fee rate.

While we are at it make the rustdocs on the getter more terse.
2025-05-31 07:51:59 +01:00
yancy 7b52b9c3a3 Fix typo 2025-05-28 20:06:31 -05:00
merge-script 6c228a3626
Merge rust-bitcoin/rust-bitcoin#4507: units: Move code out of wrapper macro
2a3e606d89 units: Move some things out of impl_u32_macro (Tobin C. Harding)

Pull request description:

  Recently we added a private `impl_u32_macro`. It included a bunch of associated consts and a pair of u32 constructor/getter functions.

  We overlooked the fact that the macro produces incorrect docs.

  Move the offending code out of the macro and into the already existent impl block for each type.

  Docs only, no other logic change.

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

Tree-SHA512: ad4bdbb35bc674e9664e293841e14dc2374c8baddf3e795edb666c75860f02728e939ef5a93ede6f4c951e92c5dd5368d6a6b9662cf6d5b268f73ab5ac97e2cc
2025-05-28 15:24:55 +00:00
Tobin C. Harding 2a3e606d89
units: Move some things out of impl_u32_macro
Recently we added a private `impl_u32_macro`. It included a bunch of
associated consts and a pair of u32 constructor/getter functions.

We overlooked the fact that the macro produces incorrect docs.

Move the offending code out of the macro and into the already existent
impl block for each type.

Docs only, no other logic change.
2025-05-27 08:36:18 +01:00
yancy 9dac4d69e0 Implement CheckedSum for Weight iterator
Expose `checked_sum` method to sum an iterator of Weights checked.
2025-05-26 19:01:56 -05: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
Fmt Bot c73131c8f0 2025-05-25 automated rustfmt nightly 2025-05-25 01:42:57 +00:00
Tobin C. Harding dc2cbc21f9
Make fee_rate test identifiers uniform
We have a bunch of unit tests, some use `f` and some use `fee_rate`.
Uniform would be better.

Elect to use the longer form just because there are only 4 instances of
the shorter one (although I personally prefer the shorter form).
2025-05-24 11:37:19 +10:00
Tobin C. Harding 2e16dbb7e5
fee_rate: Put test assertions in correct order
By convention we put assertions in the order `got` then `want`. This
makes debugging easier.
2025-05-24 11:36:28 +10: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 efae4cac8a
Merge rust-bitcoin/rust-bitcoin#4544: use Self:: instead of type aliases in error impls
0a0e23fedf style: use Self:: instead of type aliases in error impls (frankomosh)

Pull request description:

  Replace `use FooError as E` with `Self::` , during pattern matching
  on the same type in Display/Error trait implementations.

  close #4536

ACKs for top commit:
  tcharding:
    ACK 0a0e23fedf
  apoelstra:
    ACK 0a0e23fedf3552df677b379d86a1e0ac6b063152; successfully ran local tests

Tree-SHA512: 25c45a890635f990afc3bc09096929f8793007852ac435f061348bff2bd79e3faabf034d1e1e277596f4f7365477f477798f1b1e0c4b918c5b0fa08f8c49e732
2025-05-23 12:39:35 +00:00
merge-script 7dcff506dd
Merge rust-bitcoin/rust-bitcoin#4542: Fix FeeRate::checked_add/sub
395252c6d9 Fix FeeRate::checked_add/sub (Tobin C. Harding)

Pull request description:

  Currently the `checked_add` and `checked_sub` functions use a `u64` for the right hand side. This leaks the inner unit because the RHS value is implicitly in the same unit.

  Make the functions have `FeeRate` on the RHS.

ACKs for top commit:
  apoelstra:
    ACK 395252c6d95fdd581ce5e8ad5d7978515aafea23; successfully ran local tests; will one-ACK merge as this is units-only

Tree-SHA512: 1f0893f75c47f720ac741ace0274171ed24efcb6d2724d0fed941899d43b213e165b97aa050d6e40eea78c527af45d090a81b9d6cbd95835ef7105585786fca6
2025-05-23 03:57:18 +00:00
merge-script 180d9286d5
Merge rust-bitcoin/rust-bitcoin#4540: Remove `impl From<u64> for FeeRate`
c63f80baec Remove impl From<u64> for FeeRate (Tobin C. Harding)

Pull request description:

  This function leaks the inner unit of `FeeRate`. We want to change the unit, best to break downstream so they notice.

ACKs for top commit:
  apoelstra:
    ACK c63f80baec0780622d70e4c8699369b0a972cb62; successfully ran local tests; will one-ACK merge as this is units-only

Tree-SHA512: 5748f2a4cb29d6554226fe20c5479cb53081da8c2788ac31abfe1a2edb4d17f13a3b3037a840fbdc29e842af3e1accc27835fd5429c7355c1351eb8883943fdc
2025-05-23 02:51:00 +00:00
frankomosh 0a0e23fedf style: use Self:: instead of type aliases in error impls
Use  instead of 'use FooError as E' when pattern matching
on the same type in Display/Error trait implementations.
2025-05-22 20:28:33 +03:00
Tobin C. Harding c63f80baec
Remove impl From<u64> for FeeRate
This function leaks the inner unit of `FeeRate`. We want to change the
unit, best to break downstream so they notice.
2025-05-22 10:55:41 +10:00
Tobin C. Harding 395252c6d9
Fix FeeRate::checked_add/sub
Currently the `checked_add` and `checked_sub` functions use a `u64` for
the right hand side. This leaks the inner unit because the RHS value is
implicitly in the same unit.

Make the functions have `FeeRate` on the RHS.
2025-05-22 10:54:10 +10:00
Tobin C. Harding 1fef5a3dc5
units: re-order ceil/floor functions
We have 4 functions, 2 ceil, 2 floor but they are ordered ceil, floor,
floor, ceil - this causes my head to twitch when I read it.

The logic in the floor versions is easier so put them first, this is
uniform with `fee_rate/mod.rs`.

Code move only.
2025-05-22 10:50:34 +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
merge-script 855299ab7e
Merge rust-bitcoin/rust-bitcoin#4532: units: Kill mutants found in weekly mutation testing
b538a10956 Add deprecated functions to mutants exclude list (Jamil Lambert, PhD)
fd0a756344 Add tests to relative locktime (Jamil Lambert, PhD)
24cc059a78 Add tests to result (Jamil Lambert, PhD)
c1d2f0386d Add tests to block (Jamil Lambert, PhD)

Pull request description:

  Weekly mutation testing found new mutants.

  Add tests to kill the valid mutants.

  Add deprecated functions to the exclude list so they are not mutated.

  Closes #4488, Closes #4528

ACKs for top commit:
  apoelstra:
    ACK b538a1095652f535aeb15f6e3bbc44969db1ea88; successfully ran local tests
  tcharding:
    ACK b538a10956

Tree-SHA512: 8393ded6c073b2580fbb0fde9a8ce702a3d1e8c581c035870c2ba6a12d718cee577e345c9d92d0761552765248a6fb5ae9bbacbc88cac75e7153516de46de4ca
2025-05-21 15:23:44 +00:00
Jamil Lambert, PhD fd0a756344
Add tests to relative locktime
New mutants found in weekly mutation testing.

Add tests to kill them.
2025-05-20 16:05:47 +01:00
Jamil Lambert, PhD 24cc059a78
Add tests to result
New mutants found in weekly mutation testing.

Add tests to kill them.
2025-05-20 16:04:59 +01:00
Jamil Lambert, PhD c1d2f0386d
Add tests to block
New mutants found in weekly mutation testing.

Add tests to kill them.
2025-05-20 16:04:23 +01: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 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
Fmt Bot d9ec934251 2025-05-18 automated rustfmt nightly 2025-05-18 01:40:39 +00: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 532345bd11
Merge rust-bitcoin/rust-bitcoin#4508: units: Make block-related types have private inner fields
9a9b41008f units: Make block-related types have private inner fields (Tobin C. Harding)

Pull request description:

  We recently added a bunch of types in the `block` module that are wrappers around `u32`. When we did we slapped `pub` on the inner fields.

  Lets be more mindful and make the inner fields private. Note all these types have `to_u32`, `from_u32` and `From` in both directions.

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

Tree-SHA512: d4719bef57944000142ec110d4701486b4a7e5c5b24426379ed596ad83555ca1f75191fe618cc62f12b78b9d7a1ac5d18eff96bc407c9688b1210529c25329b3
2025-05-16 19:54:28 +00:00
Tobin C. Harding 9a9b41008f
units: Make block-related types have private inner fields
We recently added a bunch of types in the `block` module that are
wrappers around `u32`. When we did we slapped `pub` on the inner fields.

Lets be more mindful and make the inner fields private. Note all these
types have `to_u32`, `from_u32` and `From` in both directions.
2025-05-15 12:58:15 +10:00
merge-script 1b709eb460
Merge rust-bitcoin/rust-bitcoin#4506: units: Manually implement serde traits
e2d03fef72 units: Manually implement serde traits (Tobin C. Harding)

Pull request description:

  For types that have private inner fields we would like to manually implement `serde` traits instead of deriving them.

  This hardens the crate against making future mistakes if we want to change the inner fields.

  Do so for:

  - `Weight`
  - `BlockTime`
  - `NumberOfBlocks`
  - `NumberOf512seconds`

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

Tree-SHA512: 6d3cc4106e44e08d59f8da6f8f3285923408ed05d1c0b2f6f2d83a22718744a38bf67381177856b5713810a5f5318d929daa2d12447c722628e0576fcd075e3d
2025-05-14 16:13:10 +00:00
Tobin C. Harding e2d03fef72
units: Manually implement serde traits
For types that have private inner fields we would like to manually
implement `serde` traits instead of deriving them.

This hardens the crate against making future mistakes if we want to
change the inner fields.

Do so for:

- `Weight`
- `BlockTime`
- `NumberOfBlocks`
- `NumberOf512seconds`
2025-05-14 14:31:39 +10:00
Tobin C. Harding 980365097d
Fix expecting string for amount types
According to the `serde` docs:

> This is used in error messages. The message should complete the
> sentence “This Visitor expects to receive …”, for example the message
> could be “an integer between 0 and 64”. The message should not be
> capitalized and should not end with a period.

Use a lower case character to start the string.
2025-05-14 12:31:16 +10:00
Tobin C. Harding 3658865a18
Fix expecting string for fee_rate
According to the `serde` docs:

> This is used in error messages. The message should complete the
> sentence “This Visitor expects to receive …”, for example the message
> could be “an integer between 0 and 64”. The message should not be
> capitalized and should not end with a period.

However we have the `expecting` str using the converted type not the
thing the visitor expects.

Use `u64` instead of `FeeRate` since that is what is being parsed. Note
that in `amount` we got it _almost_ correct, subsequent patch will fix
the case.
2025-05-14 12:30:37 +10:00
Tobin C. Harding d6940497fd
Simplify fee_rate serde deserialize opt
We can just call through to the `deserialize` function. Reduces code
duplication and increases maintainability.

Refactor only, no logic change.
2025-05-14 12:25:33 +10:00
Tobin C. Harding 87d6f1718c
Make serde attribute usage more terse
The `serde` attribute can be made more terse in docs and tests with no
loss of clarity.

Refactor and docs only, no logic change.
2025-05-14 12:13:38 +10:00
merge-script fc373f3a37
Merge rust-bitcoin/rust-bitcoin#4461: Implementing Div<NonZeroU64|I64> for Amount, SignedAmount, FeeRate, and and Weight
fe577cd04e Implement Div<NonZeroU64|I64> for Amount, SignedAmount, FeeRate, and Weight (frankomosh)

Pull request description:

  The pr implements `Div<NonZeroU64>` and `Div<NonZeroI64>` for the following types in `units` crate: `Amount`, `SignedAmount`, `FeeRate`, `Weight`

  For handling owned/borrowed variants, each impl is wrapped in the existing `impl_op_for_references!` macro, which generates: `T  / NonZero*` , `&T / NonZero*`, `T  / &NonZero*`, `&T / &NonZero*`

  close: #4442

ACKs for top commit:
  Kixunil:
    ACK fe577cd04e
  apoelstra:
    ACK fe577cd04e64488371aa62b872e2b88050d4948f; successfully ran local tests
  tcharding:
    ACK fe577cd04e

Tree-SHA512: b9b4a9f46d2fcf559d0a7f62ec397b6c2b174dd8ca9d80b37c0c393894ab4bc32019d64e2afcad1f780442b16aa3d15240ce607fc14b5e17b112243f7556b5b4
2025-05-14 00:56:25 +00:00