Commit Graph

326 Commits

Author SHA1 Message Date
Tobin C. Harding f5c2248a31
units: Derive Default for BlockInterval
A block interval is a relative thing so it makes sense to default to
zero. This is the same as how we derive `Debug` for `relative::Height`
but not `absolute::Height`.
2024-12-12 15:15:28 +11:00
Tobin C. Harding a2cab6f925
units: Add _export::_core
As we do in `bitcoin` add a module for usage in macros to prevent naming
clashes if a module called `core` exists.

Overly paranoid yes but this is bitcoin after all.
2024-12-12 15:15:13 +11:00
Tobin C. Harding 38c329c1b7
Add additional catagories
Add `no-std` category to the soon-to-be-released leaf crates.
Also add `cryptography` to the `bitcoin_hashes` crate.

Close: #3731
2024-12-12 15:14:26 +11:00
merge-script 8e52f758b5
Merge rust-bitcoin/rust-bitcoin#3715: units: Add `must_use`
2fd8614f5d units: Add additional must_use (Tobin C. Harding)
79a229b391 units: Add pedantic lint return_self_not_must_use (Tobin C. Harding)

Pull request description:

  Enable return_self_must_use and also run the linter locally with must_use_candidate.

  Add must_use attribute as required excluding obvious functions (conversion, getters, etc).

  Done as part of https://github.com/rust-bitcoin/rust-bitcoin/issues/3185

ACKs for top commit:
  apoelstra:
    ACK 2fd8614f5d091377f179440b04ec71f4853fd187; successfully ran local tests; nice! will one-ACK merge

Tree-SHA512: 90868846d6877830ca2b6931e8b94208434acc5a7b21808a32e2e1568c0ad33185644b931cae500e6619b8b4f19c39bce6922502d9233173722ef0e6455edba6
2024-12-11 18:22:02 +00:00
merge-script 33f6d028ab
Merge rust-bitcoin/rust-bitcoin#3722: clippy: Set avoid-breaking-exported-api to false
adaf4ac086 Set avoid-breaking-exported-api to false (Tobin C. Harding)

Pull request description:

  These lints are valuable, lets get at em.

ACKs for top commit:
  apoelstra:
    ACK adaf4ac086553674803fadfde776d6dd013a7964; successfully ran local tests; will probably be a problem repeatedly for the next few days until we get through all currently-open PRs

Tree-SHA512: 56617a2f4aeafceef72008232cee817d45b62c040d7f1938631291c5d73627851cfbefc4b4000cd380ecb5c7e1379d1022f6cc90a4b68c819c78fb883bee0b3a
2024-12-11 15:41:06 +00:00
Jamil Lambert, PhD 4b926e1908
Change`MAX and `MIN` to equal `MAX_MONEY`
To prevent rounding errors converting to and from f64 change
`SignedAmount` `MAX` and `MIN` to +/- `MAX_MONEY` which are within the
limit in f64 that has issues.

Add checks to `from_str_in`, `checked_add`,  `checked_sub` and
`checked_mul` that the result is within MIN and MAX.

Modify tests to work with new `MIN` and `MAX`
2024-12-11 08:15:48 +00:00
merge-script 087427cf85
Merge rust-bitcoin/rust-bitcoin#3679: Support serde serializing Amount as string
c27f443520 Add basic unit tests for Amount serde (Tobin C. Harding)
22530f6a2b Support serde serializing Amount as string (Tobin C. Harding)

Pull request description:

  Sometimes JSON parsers may munge floats. Instead of using `f64` we can serialize BTC amounts as strings.

  Close: #894

ACKs for top commit:
  apoelstra:
    ACK c27f4435208cc3ca7b98580fd7e2784e089b545e; successfully ran local tests
  sanket1729:
    utACK c27f443520.

Tree-SHA512: 084669a0622557b75fceae732fb485e7139ecada48c0b65642d122e1a02f6f7e41564c3579fd10adbf3aa14c82c9f10abc3f9201858e50b729852140b31a4216
2024-12-11 04:18:53 +00:00
Tobin C. Harding adaf4ac086
Set avoid-breaking-exported-api to false
These lints are valuable, lets get at em.

Changes are API breaking but because the changes make functions consume
self for types that are `Copy` downstream should not notice the breaks.
2024-12-11 10:11:50 +11:00
Tobin C. Harding 2fd8614f5d
units: Add additional must_use
Use the `must_use_candidate` clippy lint to find all functions that are
candidates for having `must_use`.

Add `must_use` attribute but exclude obvious functions like `from_`,
`to_`, and `new`.

This patch is subjective.
2024-12-11 09:19:19 +11:00
Tobin C. Harding 79a229b391
units: Add pedantic lint return_self_not_must_use
As part of the effort to polish the `units` create ready for the 1.0
release; enable the pedantic lint `return_self_not_must_use`.
2024-12-11 08:50:27 +11:00
merge-script ec37c28fad
Merge rust-bitcoin/rust-bitcoin#3697: Range check against SignedAmount::MAX instead of i64::MAX
ac74ed2144 Range check against SignedAmount::MAX instead of i64::MAX (yancy)

Pull request description:

  Future proof this check by using SignedAmount::MAX in the case where the MAX SignedAmount changes to something other then i64::MAX.

ACKs for top commit:
  tcharding:
    ACK ac74ed2144
  apoelstra:
    ACK ac74ed2144e785fef7c395388a4fb7fb394e833e; successfully ran local tests; nice. Simple and obviously an improvement

Tree-SHA512: 4003a2f3b34e03330c57125622cab5e55a235b1a610dda622035c071bc5530811e275c2e25f40e1309cecf1c3bef35070ae690fa57fdf3e2c1b5c3f75ca5d29e
2024-12-10 16:44:10 +00:00
merge-script ecab6857bf
Merge rust-bitcoin/rust-bitcoin#3706: units: test for C-SEND-SYNC
ffdd63fa8e units: test for C-SEND-SYNC (Tobin C. Harding)

Pull request description:

  Done as part of the Rust API guidelines checklist.

  Add a unit test for `Send` and one for `Sync`.

ACKs for top commit:
  apoelstra:
    ACK ffdd63fa8ec3575bc3087241ebdcbccc71818ab7; successfully ran local tests; ooh, I like how extensible this API test framework is!

Tree-SHA512: 9227ad487f77596964c728deee97c62a04490510a8ab69fd3fc29a3e400b37114e27c777cf868fe58de870a9ff0aca3d234ccf2bb93d69a709e8c9b85d44fc61
2024-12-09 19:44:31 +00:00
merge-script b579e1238f
Merge rust-bitcoin/rust-bitcoin#3693: Change `Amount::MAX` from `u64::MAX` to `Amount::MAX_MONEY`
6950c0a7b5 Change `Amount::MAX` to equal `MAX_MONEY` (Jamil Lambert, PhD)

Pull request description:

  As discussed in #3688 and #3691 using `u64::MAX` causes errors when converting to `f64` so `MAX_MONEY` is should be used as the maximum `Amount`.

   - `Amount::MAX` changed to equal `MAX_MONEY`
   - Add a check to add, multiply and from_str functions
   - Change tests to account for new lower maximum

  Different approach to the existing PR #3692.  I have only done Amount and not SignedAmount until there is feedback on which approach to use.

ACKs for top commit:
  tcharding:
    ACK 6950c0a7b5
  apoelstra:
    ACK 6950c0a7b507f9d70c1ebdab540634482f73b247; successfully ran local tests

Tree-SHA512: 03ebf39c47b19ba88d95235538039f28bfa29f4499618fab25c9b627684c348ed41caef682e8f0e01ca62cf9ced8a1183fe3ed861bffeb9609b09440ddfb1c92
2024-12-09 14:54:39 +00:00
Tobin C. Harding ffdd63fa8e
units: test for C-SEND-SYNC
Done as part of the Rust API guidelines checklist.

Add a unit test for `Send` and one for `Sync`.
2024-12-09 10:54:07 +11:00
yancy ac74ed2144 Range check against SignedAmount::MAX instead of i64::MAX
Future proof this check by using SignedAmount::MAX in the case where the
MAX SignedAmount changes to something other then i64::MAX.
2024-12-06 09:20:12 -06:00
Jamil Lambert, PhD 6950c0a7b5
Change `Amount::MAX` to equal `MAX_MONEY`
To prevent rounding errors converting to and from f64 change
`Amount::MAX` to `MAX_MONEY` which is below the limit in f64 that has
issues.

Add checks to `from_str_in`, `checked_add` and `checked_mul` that the
result is below MAX, where previously a u64 overflow was relied on.

Change tests to account for new lower MAX that is within the range of
SignedAmount and does not overflow so easily

Remove overflow tests

`Amount::MAX` is now below `u64::MAX` and within the range of values for
`SignedAmount`.   These tests therefore do not overflow.
In effective_value there is no error with `Amount::MAX` and the correct
value is returned.
In psbt the removed test is effectively the same as the previous test.

Modify `Amount` tests to work with new `MAX`

Tests need to be changed that checked values above the new `MAX` or
`Amount::MAX` was out of range for `SignedAmount` which it isn't anymore
2024-12-04 14:17:00 +00:00
Tobin C. Harding edab380ac0
bitcoin: Bump version to v0.33.0-alpha.0
Needs release notes but there are 20 pages of them, that feels like too
many to go through manually.

Includes a missing changelog entry in `units` for an already released
change that is included in this `bitcoin` release.
2024-12-04 15:58:36 +11:00
Tobin C. Harding c27f443520
Add basic unit tests for Amount serde
Add a test each for serializing `Amount` as sat, as BTC, and as str.
2024-12-03 08:43:35 +11:00
Tobin C. Harding 22530f6a2b
Support serde serializing Amount as string
Sometimes JSON parsers may munge floats. Instead of using `f64` we can
serialize BTC amounts as strings.

Includes addition of `alloc` feature gate to `DisplayFullError` to
remove lint warnings when building with `--no-default-features`.

Close: #894
2024-12-03 08:42:41 +11:00
merge-script 58b087d946
Merge rust-bitcoin/rust-bitcoin#3674: Close `amounts` error types
fd2a5c1ec7 Close amounts error types (Tobin C. Harding)
23c77275b1 Reduce code comment lines (Tobin C. Harding)
d595f421c6 Remove whitespace between enum variants (Tobin C. Harding)

Pull request description:

  Close the two pubic enum error types in `units::amounts`. All the other structs are closed already because they either have private fields or marked `non_exhaustive`.

ACKs for top commit:
  apoelstra:
    ACK fd2a5c1ec79f337fb3695c030c9fb6b4671468f2; successfully ran local tests; thanks!

Tree-SHA512: f8d68ef821449e0829c926cf527df4b226b29c8d1d41b320a016fbf70b4b39cc54c8c218955caa0c3776158eeeae0ebacc1cc89dab67bafc399b94063324ab0e
2024-12-02 03:04:07 +00:00
Tobin C. Harding fd2a5c1ec7
Close amounts error types
Close the two pubic enum error types in `units::amounts`. All the other
structs are closed already because they either have private fields or
marked `non_exhaustive`.
2024-12-02 09:14:14 +11:00
Tobin C. Harding 23c77275b1
Reduce code comment lines
Make the comment more terse by using 'info' instead of 'information' and
reduce the line count by 2.
2024-12-02 09:14:06 +11:00
Fmt Bot 0990b30035 2024-12-01 automated rustfmt nightly 2024-12-01 01:41:12 +00:00
merge-script 85d1eb8289
Merge rust-bitcoin/rust-bitcoin#3677: units: Implement `iter::Sum` for all types that implement `ops::Add`
433f70939c Implement iter::Sum for BlockInterval (Tobin C. Harding)
0369e64b56 Implement Sum for an iterator of references to amounts (Tobin C. Harding)
31f883ac00 Implement iter::Sum for FeeRate (Tobin C. Harding)

Pull request description:

  Enables summing an iterator of values. Note that this does not include either `LockTime`s. `absolute::LockTime` should not be added and for `relative::LockTime` we have https://github.com/rust-bitcoin/rust-bitcoin/issues/3676

  Close: #1638

ACKs for top commit:
  apoelstra:
    ACK 433f70939c3ecc10702ab6502e3f9bcd94dab739; successfully ran local tests; nice!
  sanket1729:
    utACK 433f70939c

Tree-SHA512: 1eda00f3bbbc61f795198ce8525a5a9b690478a8abc268da6d2e40de7d91decc28dd8211df0c6abeaf30148c7ec3907b85e3c5351972c354590569840e84d562
2024-11-29 13:28:30 +00:00
merge-script 7d8b9bd883
Merge rust-bitcoin/rust-bitcoin#3673: units: Close the hex parse errors
22769268f3 units: Close the hex parse errors (Tobin C. Harding)

Pull request description:

  As part of the 1.0 effort close the errors in the `units::parse` module.

ACKs for top commit:
  apoelstra:
    ACK 22769268f34b45c0bd86c548eb13cfe1e290f0d7; successfully ran local tests; thanks!
  sanket1729:
    ACK 22769268f3

Tree-SHA512: 598ba236f8c08c3f750112e0d8b8e0aa0568be2700a328e4a2d8999ca59eada8a16a6a1d9e9121e7f42ce9bbe3da3f87221ba67c36056996a687e489f4c6007c
2024-11-29 03:41:48 +00:00
merge-script 99bf3f74b9
Merge rust-bitcoin/rust-bitcoin#3680: units: Test C-COMMON-TRAITS
c49f40fd9a units: Test C-COMMON-TRAITS (Tobin C. Harding)

Pull request description:

  Add structs to the `api` integration test file that verify the set of common traits.

ACKs for top commit:
  apoelstra:
    ACK c49f40fd9af1b9446a7c9a35aefdc02b30801275; successfully ran local tests; good idea!

Tree-SHA512: bc60ed8912e705d4c07714e9d19c0eee4fb2eb6be17a6ee67c2bb922ea27ef3a737eda3f7de690fa3a9fa364c34029989f20361d03f706fd3152ec4f20f33aab
2024-11-28 23:27:42 +00:00
merge-script 31bf3f1931
Merge rust-bitcoin/rust-bitcoin#3659: Add string regression tests in leaf crates
7e17eaf21c units: Add stringy regression tests (Tobin C. Harding)

Pull request description:

  Add regression tests for `Display` and `FromStr` impls. Exclude error types and helper types (`amount::Display`).

  Done as part of #2498 and also as part of the 1.0'ing effort.

ACKs for top commit:
  apoelstra:
    ACK 7e17eaf21c479338d5161b493f02578ef4186e62; successfully ran local tests; nice

Tree-SHA512: 6484806777501fe38557987c9c39b377f972fd4406cf3cfd8ac36f8426041484caab45d4ccff87221dbc5c34507d1be6a7b23839367bd3010855c92fd898c835
2024-11-28 22:47:53 +00:00
Tobin C. Harding c49f40fd9a
units: Test C-COMMON-TRAITS
Add structs to the `api` integration test file that verify the set of
common traits.
2024-11-28 16:59:00 +11:00
Tobin C. Harding 433f70939c
Implement iter::Sum for BlockInterval
We support adding two intervals; no obvious reason not to support
summing an iterator of intervals.
2024-11-28 15:56:07 +11:00
Tobin C. Harding 0369e64b56
Implement Sum for an iterator of references to amounts
We have `iter::Sum` already for `Amount` and `SignedAmount`. Add
an implementation for each to support iterators that yield references.
2024-11-28 15:51:29 +11:00
Tobin C. Harding 31f883ac00
Implement iter::Sum for FeeRate
The `FeeRate` implements `ops::Add`, no reason not to enable summing an
iterator of fee rates.
2024-11-28 15:49:01 +11:00
Tobin C. Harding d595f421c6
Remove whitespace between enum variants
We don't tend to put whitespace between enum variants.
2024-11-28 13:45:01 +11:00
Tobin C. Harding 22769268f3
units: Close the hex parse errors
As part of the 1.0 effort close the errors in the `units::parse` module.
2024-11-28 13:36:09 +11:00
Tobin C. Harding 77085a1fa1
units: Remove serde from amounts
The `Amount` and `SignedAmount` were not supposed to implement `serde`
traits by design because doing so implicitly uses sats. We provide two
modules `as_sat` and `as_btc` to allow users to explicitly serialize in
their preferred format.

In commit: `d57ec019d5 Use Amount type for TxOut value field` derives
were added for `serde` and we did not notice it during review.
2024-11-28 12:55:43 +11:00
Tobin C. Harding 7e17eaf21c
units: Add stringy regression tests
Add regression tests for `Display` and `FromStr` impls.

Exclude error types and helper types (`amount::Display`).
2024-11-27 13:35:45 +11:00
merge-script f27a788288
Merge rust-bitcoin/rust-bitcoin#3639: units: Add integration test of API surface
7b8369f381 units: Add integration test of API surface (Tobin C. Harding)

Pull request description:

  In an effort to check off items in the Rust API guidelines checklist (#3632) add an integration test file that tests:

  - The location of re-exports for various typical usage styles.
  - Regressions in the API surface (things being accidentally moved).
  - All public types implement Debug (C-DEBUG).
  - For all non-error types:
      - `Debug` representation is never empty (C-DEBUG-NONEMPTY)
  - For all error types:
      - Derive standard traits as defined by `rust-bitcoin` policy.
  - All data structures implement `serde` traits (C-SERDE).

  I used the `cargo check-api` script we have laying around from ages ago (#2986) to parse `units` and get a list of the public types.

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

Tree-SHA512: 6fa2a61f6b67a6b5a56950b87e6df68b761b69bd2a49e7aac48aa238cb84441ce04acd85097d28ae4055058052a7491eccda3da218812149a896e548b4018aaa
2024-11-25 23:48:42 +00:00
merge-script d54c04be00
Merge rust-bitcoin/rust-bitcoin#3647: units: Comment alloc feature
17ca5018eb units: Comment alloc feature (Tobin C. Harding)

Pull request description:

  Add a comment to the `serde` module about why we have all the `alloc` feature gating.

  Done as part of #3556 - auditing the whole crate for use of `alloc` feature.

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

Tree-SHA512: 6d13129903a9c530db811e9f64ae4fa653dbcc952a42502c53c6c622a80c1e58b3037edd0638de78867823ca370b3a4595a08a9ec07b84c71afb6200454f5d6d
2024-11-25 13:32:18 +00:00
Tobin C. Harding 7b8369f381
units: Add integration test of API surface
In an effort to check off items in the Rust API guidelines
checklist (#3632) add an integration test file that tests:

- The location of re-exports for various typical usage styles.
- Regressions in the API surface (things being accidentally moved).
- All public types implement Debug (C-DEBUG).
- For all non-error types:
    - `Debug` representation is never empty (C-DEBUG-NONEMPTY)
- For all error types:
    - Derive standard traits as defined by `rust-bitcoin` policy.

I used the `cargo check-api` script we have laying around from ages
ago (#2986) to parse `units` and get a list of the public types.
2024-11-25 13:33:15 +11:00
merge-script e0ba1b661c
Merge rust-bitcoin/rust-bitcoin#3636: Mark `checked_` functions as `const`
a8379bf005 Mark `checked_` functions const in bitcoin. (Jamil Lambert, PhD)
fe10ff2eb7 Mark functions `const` in `units` (Jamil Lambert, PhD)

Pull request description:

  Following on #3608, #3627 and #1174 the rest of the `checked_` functions in all `rust-bitcoin` have been marked as const.  Except for tests and traits.

ACKs for top commit:
  apoelstra:
    ACK a8379bf0053e66cf5984ce449d19e54e529b6b70; successfully ran local tests; thanks! I find this much easier to read
  tcharding:
    ACK a8379bf005

Tree-SHA512: b8d97b7a3d9fc33b57349f418ccc5aac2f3e8c4145a73bf0e24e85547217d41214696e9a80b1fb5a1bae7e766aad1c2b5df6044564772fe76cec9b3628bcd8e5
2024-11-23 11:46:29 +00:00
Tobin C. Harding 17ca5018eb
units: Comment alloc feature
Add a comment to the `serde` module about why we have all the `alloc`
feature gating.

Done as part of #3556 - auditing the whole crate for use of `alloc`
feature.
2024-11-22 10:42:17 +11:00
Jamil Lambert, PhD fe10ff2eb7
Mark functions `const` in `units`
Mark `checked_` functions const. Replace `map()` and `?` operators,
which are not allowed in const context, with match statements.
Use descriptive variable names in ceiling division to make
it easier to follow.
2024-11-18 14:54:01 +00:00
Fmt Bot 500cd10802 2024-11-17 automated rustfmt nightly 2024-11-17 01:23:55 +00:00
Jamil Lambert, PhD 68aac98753
Mark functions `const`
Mark `checked_` functions const.
Replace `map()` and `?` operators, which are not allowed in const
context, with match statements.
2024-11-15 15:58:52 +00:00
merge-script 3ba3079edf
Merge rust-bitcoin/rust-bitcoin#3614: Add test case
4223655829 Add test case (yancy)

Pull request description:

  Since there are test cases for other functions here, add test case as follow up for https://github.com/rust-bitcoin/rust-bitcoin/pull/3604.  I forgot to request this during review.

ACKs for top commit:
  apoelstra:
    ACK 422365582964cf405529de3a1cf63d766b0d0e2e; successfully ran local tests
  tcharding:
    ACK 4223655829

Tree-SHA512: 8629cfff3e3eb800aa4d4625627e0a777c389566f4125bc63e67fe4c5a597ca63b9fb92da42f6c9dab12e6c63839eef35a13957f98606a37ed687eb96d896c2e
2024-11-15 04:24:13 +00:00
merge-script 7f1237572f
Merge rust-bitcoin/rust-bitcoin#3621: Remove Amount::fmt_value_in
0348801ef3 Remove Amount::fmt_value_in (Shing Him Ng)

Pull request description:

  Saw this mentioned in #3556

  Fixes #2952

ACKs for top commit:
  apoelstra:
    ACK 0348801ef30d1cdfdc40cd2316671532d4c06141; successfully ran local tests
  tcharding:
    ACK 0348801ef3

Tree-SHA512: 29a1d230672a22d059d2ef0870e68dec0fe6d6ae9d3fed51275d9b6779d097578a38a514544df11bdf23908c2d8e3c5fd5c6de2e460aab9792770d6b9e396fc6
2024-11-14 21:44:32 +00:00
yancy 4223655829 Add test case 2024-11-14 13:22:22 -06:00
merge-script 72760bbe96
Merge rust-bitcoin/rust-bitcoin#3606: Deprecate function
eacb1e7831 Deprecate function (yancy)

Pull request description:

  closes https://github.com/rust-bitcoin/rust-bitcoin/issues/3602

ACKs for top commit:
  tcharding:
    ACK eacb1e7831
  apoelstra:
    ACK eacb1e7831bdf2058a674a106b91447c1fe9470e; successfully ran local tests; lol

Tree-SHA512: 9da7881ee62e1808d83c92e232cef42055cce6e3ba03dc1001472948380c16a1968da1d4ce4f7ad13d78d1d70e143851f2635ba167c4df34be61ecf3f2fdee4e
2024-11-14 18:21:20 +00:00
yancy eacb1e7831 Deprecate function 2024-11-13 22:31:24 -06:00
Shing Him Ng 0348801ef3 Remove Amount::fmt_value_in 2024-11-13 19:49:26 -06:00
yancy 971167d0fd Remove test suffix from test names 2024-11-13 17:04:14 -06:00
merge-script 7315ca9a4e
Merge rust-bitcoin/rust-bitcoin#3608: Mark funtions const
4c94695942 Mark funtions const (yancy)

Pull request description:

  May as well mark these const as well.  Follow up to https://github.com/rust-bitcoin/rust-bitcoin/pull/3605

ACKs for top commit:
  apoelstra:
    ACK 4c94695942de41e5eca4ac120db2e069c0bb037d; successfully ran local tests; yeah, I think this are all worth consting
  tcharding:
    ACK 4c94695942
  sanket1729:
    ACK 4c94695942

Tree-SHA512: bf41e416cb8a2eb90e26d7bd640df5c2a5a868e3b721bde7cc8a3b97c687bab4d1cb4ab1c4b04ed625e8657e25c59e386720cb0f9d735ffc492e98f5b8b2ca3c
2024-11-13 14:47:40 +00:00
merge-script a9bc1c7db5
Merge rust-bitcoin/rust-bitcoin#3605: Mark function as const
1db4b723dc Mark function as const (yancy)

Pull request description:

  We discussed marking from_vb as const here: https://github.com/rust-bitcoin/rust-bitcoin/issues/3602

  However, from what I can tell, map() isn't const and I don't see a tracking issue for changing it.  Also, the question mark operator isn't available in const context either, although there is a tracking issue for that: https://github.com/rust-lang/rust/issues/74935.  It will be a long while before that makes it into this projects MSRV if/when it lands.

  There are some other functions in this module that could use the same re-write to make them const as well it looks like.

ACKs for top commit:
  tcharding:
    ACK 1db4b723dc
  apoelstra:
    ACK 1db4b723dc59568c14c76598e7c63c58651ed1cd; successfully ran local tests

Tree-SHA512: 62b612791dd3ce2f6ebf27f586a1262633a46566b9fd3583984171f62209714ad979439345fe86d8ef87d2f78a2cee21d619e2eb3621689faf59d81640e9f77c
2024-11-13 02:01:09 +00:00
yancy 4c94695942 Mark funtions const 2024-11-12 18:16:12 -06:00
yancy 1db4b723dc Mark function as const 2024-11-12 16:10:38 -06:00
Rob N b96501981f
feat(units): add kvb constructor to `FeeRate`
Namely, the feefilter expresses the fee as sat per 1000 vbyte
2024-11-12 08:13:53 -10:00
Tobin C. Harding 84ede349b0
Run the formatter
Run `just fmt`, no manual changes.
2024-11-11 14:19:17 +11:00
yancy 8b928a1515 Split checked_div_by_weight into floor and ceiling version 2024-11-07 16:28:44 -06:00
Jamil Lambert, PhD 1649b68589
Standardize wording to `constructs a new`
There is a range of different wordings used in the docs of constructor
type functions.

Change all to start with `Constructs a new` or `Constructs an empty`.
2024-11-05 13:02:26 +00:00
Jamil Lambert, PhD 27f94d5540
Replace `creates` with `constructs`
In functions that act like constructors there is a mixture of the usage
of `creates` and `constructs`.

Replace all occurrences of `creates` with `constructs` in the first line
of docs of constructor like functions.
2024-11-05 12:47:28 +00:00
merge-script 3b0cb0e87d
Merge rust-bitcoin/rust-bitcoin#3539: Improve the `amount` module
81d8699b55 units: Put no_std up top (Tobin C. Harding)
3e332c3839 amount: Fix docs on FromStr (Tobin C. Harding)
5bec76aa51 amount: Fix rustdocs (Tobin C. Harding)
41c80cc476 amount: Improve docs on div by weight (Tobin C. Harding)
2b4a61739a Add type to debug output for Amount (Tobin C. Harding)
42e5043b33 Add from_int_btc group of functions (Tobin C. Harding)

Pull request description:

  Improve the `amount` module by doing:

  - Patch 1: Add/update `from_int_btc` and `from_int_btc_const` functions
  - Patch 2:  Add type to debug output for `Amount`
  - Patch 3: Fix incorrect docs
  - Patch 4: Make docs use correct style and be uniform across the two amount types
  - Patch 5: Fix docs on `FromStr`

ACKs for top commit:
  apoelstra:
    ACK 81d8699b55dad570247cb14d2b3eea64270a83cf; successfully ran local tests
  jamillambert:
    ACK 81d8699b55

Tree-SHA512: ddd6e02b4cd9a9aa8cbdd2d2f7ae289a6bcca9eb002ef0c6d83a6eca950b2cd08f5918286bb33e814f321e3bfe83fdf75ae051cf8f91ee45d3e4abe76c1c2a4c
2024-11-04 23:32:41 +00:00
Tobin C. Harding 81d8699b55
units: Put no_std up top
The `no_std` attribute has significant ramifications, as opposed to the
clippy attributes etc.

Put the `no_std` attribute up top so it catches the eye. This is also
uniform with other crates in this repo.
2024-11-05 07:49:35 +11:00
Tobin C. Harding 3e332c3839
amount: Fix docs on FromStr
The docs on `FromStr` say "string slice is zero" but actually mean to
document the behaviour when the value represented is zero.

Also the fact that `FromStr` returns an error if parsing fails is self
evident.
2024-11-05 07:49:35 +11:00
Tobin C. Harding 5bec76aa51
amount: Fix rustdocs
Fix the rustdocs on `Amount` and `SignedAmount` by doing:

- Make them uniform
- Use correct style (looks like `SignedAmount` got left behind when we
  improved `Amount`)
2024-11-05 07:49:35 +11:00
Tobin C. Harding 41c80cc476
amount: Improve docs on div by weight
Make an effort to improve the docs on `Amount::checked_div_by_weight`
and `ops::Div<weight> for Amount`.
2024-11-05 07:49:28 +11:00
Fmt Bot 5ecf7f2d67 2024-11-03 automated rustfmt nightly 2024-11-03 01:21:14 +00:00
Tobin C. Harding 2b4a61739a
Add type to debug output for Amount
Debug output usually includes the type (and we do so for
`SignedAmount`). Add the type to the `Debug` output of `Amount`.
2024-11-02 10:19:03 +11:00
Tobin C. Harding 42e5043b33
Add from_int_btc group of functions
Add/update the from_int group of functions to provide one that errors
and one that is const and panics (errors in const context are not useful
because one cannot call `unwrap` in const context).
2024-11-02 10:19:03 +11:00
Tobin C. Harding 38b8c6f5ea
units: Remove a bunch of feature gateing
Remove `alloc` feature gating from all modules in `units`!
2024-11-02 08:24:28 +11:00
Tobin C. Harding e347b50614
Use InputString in hex prefix error types
In an effort to reduce requirement for `alloc`; remove the `String` and
use `InputString` in the hex prefix related error types.

Tested with:

(Note in test code we have to use `"cafe".to_owned()` before this patch
is applied.)

rust```
    #[test]
    fn hex_prefix_errors() {
        let err = hex_remove_prefix("cafe").unwrap_err();
        std::println!("{}", err);
        std::println!("{:?}", err);

        let err = hex_check_unprefixed("0xcafe").unwrap_err();
        std::println!("{}", err);
        std::println!("{:?}", err);
    }
```

Before:

hex string is missing a prefix (e.g. 0x): cafe
MissingPrefixError { hex: "cafe" }
hex string contains a prefix: 0xcafe
ContainsPrefixError { hex: "0xcafe" }

After:

failed to parse 'cafe' as hex because it is missing the '0x' prefix
MissingPrefixError { hex: InputString("cafe") }
failed to parse '0xcafe' as hex because it contains the '0x' prefix
ContainsPrefixError { hex: InputString("0xcafe") }
2024-11-02 08:24:27 +11:00
Tobin C. Harding ff20249bdc
Remove unneeded feature gate
We can use the `parse::hex_remove_optional_prefix` now without the
feature gate.
2024-11-02 07:42:57 +11:00
Tobin C. Harding 88f6621e30
Split parse macros
Done in preparation for enabling no-alloc builds.

Split the macro calls to handle `str` separately from `alloc` types.
2024-11-02 07:42:57 +11:00
merge-script 515c0f584a
Merge rust-bitcoin/rust-bitcoin#3559: Replace `String` with `InputString`
3f2e760d1f Replace String with InputString in ParseIntError (Tobin C. Harding)
aa5c78430c Replace invalidInteger with ParseIntError (Tobin C. Harding)
9b7a706bfd Remove From<ParseIntError> (Tobin C. Harding)
c90f4b6033 Fix bug in error output (Tobin C. Harding)
c986b2f620 internals: Move error.rs to error/mod.rs (Tobin C. Harding)

Pull request description:

  This PR hopefully clears the way for removing many of the `alloc` feature gates in `units` and `primitives`

  The three final patches were tested by adding the following test to `units::locktime::absolute`:
  ```rust
      #[test]
      pub fn debug_absolute_error_conversion_height() {
          let invalid_height = LOCK_TIME_THRESHOLD + 1;
          let err = Height::from_consensus(invalid_height).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let invalid_time =  LOCK_TIME_THRESHOLD - 1;
          let err = Time::from_consensus(invalid_time).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let invalid_height = std::format!("{:x}", LOCK_TIME_THRESHOLD + 1);
          let err = Height::from_hex(&invalid_height).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let invalid_time = std::format!("{:x}", LOCK_TIME_THRESHOLD - 1);
          let err = Time::from_hex(&invalid_time).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let err = Height::from_hex("somerandomshit").unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let err = Time::from_hex("somerandomshit").unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);
      }
  ```

  Gives the following output (the last four lines is the bit that changes, the rest just proves we don't break other variants)

  On commit: `d47ff1c25 Remove From<ParseIntError>`

  ConversionError { unit: Blocks, input: 500000001 }
  invalid lock time value 500000001, expected lock-by-blockheight (must be < 500000000)
  ConversionError { unit: Seconds, input: 499999999 }
  invalid lock time value 499999999, expected lock-by-blocktime (must be >= 500000000)
  ParseHeightError(Conversion(500000001))
  block height 500000001 is above limit 499999999
  ParseTimeError(Conversion(499999999))
  block height 499999999 is below limit 500000000
  ParseHeightError(InvalidInteger { source: ParseIntError { kind: InvalidDigit }, input: "somerandomshit" })
  failed to parse somerandomshit as block height
  ParseTimeError(InvalidInteger { source: ParseIntError { kind: InvalidDigit }, input: "somerandomshit" })
  failed to parse somerandomshit as block time

  On commit: `0155a0d9a Replace invalidInteger with ParseIntError`

  ConversionError { unit: Blocks, input: 500000001 }
  invalid lock time value 500000001, expected lock-by-blockheight (must be < 500000000)
  ConversionError { unit: Seconds, input: 499999999 }
  invalid lock time value 499999999, expected lock-by-blocktime (must be >= 500000000)
  ParseHeightError(Conversion(500000001))
  block height 500000001 is above limit 499999999
  ParseTimeError(Conversion(499999999))
  block height 499999999 is below limit 500000000
  ParseHeightError(ParseInt(ParseIntError { input: "somerandomshit", bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse somerandomshit as block height
  ParseTimeError(ParseInt(ParseIntError { input: "somerandomshit", bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse somerandomshit as block time

  On Commit: `3f2e760d1 Replace String with InputString in ParseIntError`

  ConversionError { unit: Blocks, input: 500000001 }
  invalid lock time value 500000001, expected lock-by-blockheight (must be < 500000000)
  ConversionError { unit: Seconds, input: 499999999 }
  invalid lock time value 499999999, expected lock-by-blocktime (must be >= 500000000)
  ParseHeightError(Conversion(500000001))
  block height 500000001 is above limit 499999999
  ParseTimeError(Conversion(499999999))
  block time 499999999 is below limit 500000000
  ParseHeightError(ParseInt(ParseIntError { input: InputString("somerandomshit"), bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse 'somerandomshit' as absolute Height/Time (block height)
  ParseTimeError(ParseInt(ParseIntError { input: InputString("somerandomshit"), bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse 'somerandomshit' as absolute Height/Time (block time)

ACKs for top commit:
  apoelstra:
    ACK 3f2e760d1fef2951f93a2554cd53340b0d7a6e0b; successfully ran local tests; nice!

Tree-SHA512: f7fd55acfb83082419db22c24a6b375c20e2631263401e500410c5b5659463f06dc4bdb145621e475dc15d75e764668cdcbf8f88006a487248a05fdb237ad136
2024-11-01 16:27:07 +00:00
Tobin C. Harding 3f2e760d1f
Replace String with InputString in ParseIntError
Currently the `ParseIntError` contains an owned copy of the input
string, this is causing us to have to use `alloc` everywhere.

We already have a alloc-friendly string replacement type, the
`InputString` - use it.
2024-11-01 17:31:22 +11:00
Tobin C. Harding aa5c78430c
Replace invalidInteger with ParseIntError
We have a special type for wrapping integer parsing errors, use it.

To test this I added the following tests:

    #[test]
    pub fn debug_absolute_error_conversion_height() {
        let invalid_height = LOCK_TIME_THRESHOLD + 1;
        let _ = Height::from_consensus(invalid_height).unwrap();
    }

    #[test]
    pub fn debug_absolute_error_conversion_time() {
        let invalid_time =  LOCK_TIME_THRESHOLD - 1;
        let _ = Time::from_consensus(invalid_time).unwrap();
    }

    #[test]
    #[cfg(feature = "std")]
    pub fn debug_absolute_error_conversion_height_string() {
        let invalid_height = std::format!("{:x}", LOCK_TIME_THRESHOLD + 1);
        let _ = Height::from_hex(&invalid_height).unwrap();
    }

    #[test]
    #[cfg(feature = "std")]
    pub fn debug_absolute_error_conversion_time_string() {
        let invalid_time = std::format!("{:x}", LOCK_TIME_THRESHOLD - 1);
        let _ = Time::from_hex(&invalid_time).unwrap();
    }

    #[test]
    #[cfg(feature = "std")]
    pub fn debug_absolute_error_height_invalid_hex_string() {
        let _ = Height::from_hex("somerandomshit").unwrap();
    }

    #[test]
    #[cfg(feature = "std")]
    pub fn debug_absolute_error_time_invalid_hex_string() {
        let _ = Time::from_hex("somerandomshit").unwrap();
    }

Which resulted in the following output

Before:

---- locktime::absolute::tests::debug_absolute_error_conversion_height stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_height' panicked at units/src/locktime/absolute.rs:431:56:
called `Result::unwrap()` on an `Err` value: ConversionError { unit: Blocks, input: 500000001 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- locktime::absolute::tests::debug_absolute_error_conversion_height_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_height_string' panicked at units/src/locktime/absolute.rs:444:51:
called `Result::unwrap()` on an `Err` value: ParseHeightError(Conversion(500000001))

---- locktime::absolute::tests::debug_absolute_error_conversion_time stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_time' panicked at units/src/locktime/absolute.rs:437:52:
called `Result::unwrap()` on an `Err` value: ConversionError { unit: Seconds, input: 499999999 }

---- locktime::absolute::tests::debug_absolute_error_height_invalid_hex_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_height_invalid_hex_string' panicked at units/src/locktime/absolute.rs:457:52:
called `Result::unwrap()` on an `Err` value: ParseHeightError(InvalidInteger { source: ParseIntError { kind: InvalidDigit }, input: "somerandomshit" })

---- locktime::absolute::tests::debug_absolute_error_conversion_time_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_time_string' panicked at units/src/locktime/absolute.rs:451:47:
called `Result::unwrap()` on an `Err` value: ParseTimeError(Conversion(499999999))

---- locktime::absolute::tests::debug_absolute_error_time_invalid_hex_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_time_invalid_hex_string' panicked at units/src/locktime/absolute.rs:464:50:
called `Result::unwrap()` on an `Err` value: ParseTimeError(InvalidInteger { source: ParseIntError { kind: InvalidDigit }, input: "somerandomshit" })

After:

---- locktime::absolute::tests::debug_absolute_error_conversion_height stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_height' panicked at units/src/locktime/absolute.rs:432:56:
called `Result::unwrap()` on an `Err` value: ConversionError { unit: Blocks, input: 500000001 }

---- locktime::absolute::tests::debug_absolute_error_conversion_height_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_height_string' panicked at units/src/locktime/absolute.rs:445:51:
called `Result::unwrap()` on an `Err` value: ParseHeightError(Conversion(500000001))

---- locktime::absolute::tests::debug_absolute_error_conversion_time stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_time' panicked at units/src/locktime/absolute.rs:438:52:
called `Result::unwrap()` on an `Err` value: ConversionError { unit: Seconds, input: 499999999 }

---- locktime::absolute::tests::debug_absolute_error_conversion_time_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_conversion_time_string' panicked at units/src/locktime/absolute.rs:452:47:
called `Result::unwrap()` on an `Err` value: ParseTimeError(Conversion(499999999))

---- locktime::absolute::tests::debug_absolute_error_height_invalid_hex_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_height_invalid_hex_string' panicked at units/src/locktime/absolute.rs:458:52:
called `Result::unwrap()` on an `Err` value: ParseHeightError(ParseInt(ParseIntError { input: "somerandomshit", bits: 32, is_signed: false, source: ParseIntError { kind: InvalidDigit } }))

---- locktime::absolute::tests::debug_absolute_error_time_invalid_hex_string stdout ----
thread 'locktime::absolute::tests::debug_absolute_error_time_invalid_hex_string' panicked at units/src/locktime/absolute.rs:465:50:
called `Result::unwrap()` on an `Err` value: ParseTimeError(ParseInt(ParseIntError { input: "somerandomshit", bits: 32, is_signed: false, source: ParseIntError { kind: InvalidDigit } }))
2024-11-01 17:31:22 +11:00
Tobin C. Harding 9b7a706bfd
Remove From<ParseIntError>
The errors in `units::locktime::absolute` are complex, I'd like to make
them more simple so they are more understandable.

I have no clue why this is implemented - remove it.
2024-11-01 17:31:22 +11:00
Tobin C. Harding c90f4b6033
Fix bug in error output
`ParseTimeError` should say "block time" not "block height". This looks
like a cut'n pasta error because the `ParseHeightError` uses the same
string.
2024-11-01 17:31:21 +11:00
Tobin C. Harding 6aa8c2b023
Remove needless_borrows_for_generic_args
This has been fixed and we use nightly to lint so we have access to the
merged fix.

Removing the attribute uncovers a bunch of real lint warnings, fix
them while we are at it.
2024-11-01 14:30:45 +11:00
Tobin C. Harding 10ff979fbd
amount: Move arbitrary impl
In an effort to make the `unsigned` and `signed` files be diff'able move
the `arbitrary` code to be in the same place.

Code move only.
2024-10-31 12:57:08 +11:00
Tobin C. Harding d4d9311603
amount: Move SignedAmount to private signed module
In an effort to make the `amount` module more readable move the
`SignedAmount` type to a private submodule.

Re-export everything so this is not a breaking change.

Code move and re-exports only.
2024-10-31 12:57:08 +11:00
Tobin C. Harding 0fc0e8760b
docs: Remove link from self
When we move `SignedAmount` to a submodule linking to `self` introduces
a clippy warning, I'm not exactly sure why but lets remove the link in
preparation for the move.
2024-10-31 12:57:03 +11:00
Tobin C. Harding 13f9fd1b77
amount: Move Amount to private unsigned module
In an effort to make the `amount` module more readable move the `Amount`
type to a private submodule.

Re-export everything so this is not a breaking change.

Code move and re-exports only.
2024-10-31 12:56:40 +11:00
Tobin C. Harding 2d4c0fa6c1
amount: Format serde file
Done as a separate patch so that the diff of the verification code move
was less noisy.
2024-10-31 12:29:21 +11:00
Tobin C. Harding df96267342
amount: Move serde code to submodule
No changes other than moving the module code.
2024-10-31 12:29:21 +11:00
Tobin C. Harding 87c9a3fd11
amount: Format tests file
Done as a separate patch so that the diff of the verification code move
was less noisy.
2024-10-31 12:29:21 +11:00
Tobin C. Harding e0bc68042d
amount: Move test code to submodule
In preparation for splitting the two amounts into separate files; move
the `amount` module code to a submodule.

Internal change only.
2024-10-31 12:29:20 +11:00
Tobin C. Harding 7e1269704d
tests: Use from_sat
Stop using private constructor in unit tests, use `from_sat` instead.
2024-10-31 12:29:20 +11:00
Tobin C. Harding cd5d1aba2f
amount: Format verification file
Done as a separate patch so that the diff of the verification code move
was less noisy.
2024-10-31 12:29:20 +11:00
Tobin C. Harding 01f907b7a6
amount: Move verification code to submodule
Code move only, no other changes.
2024-10-31 12:29:20 +11:00
Tobin C. Harding 5ce827c5e0
amount: Move error code to submodule
There is _a lot_ of error types in the `amount` module. Move them to a
separate `error` module.

Add a bunch of `pub(super)` to keep things private to the `amount`
module.

Eventually we will want to close all these errors.
2024-10-31 12:29:16 +11:00
Tobin C. Harding abc54d0343
Make amount module a directory
In preparation for splitting the error types out of `amount.rs` into
their own file move the `amount.rs` file to `amount/mod.rs`.

File move only, no other changes.
2024-10-31 09:52:32 +11:00
Casey Rodarmor 1d2cfb036c Make `Amount::to_sat` and `SignedAmount::to_sat` const 2024-10-19 11:49:14 -07:00
merge-script 17899d1b8c
Merge rust-bitcoin/rust-bitcoin#3475: Unify deprecated note field format
88b53a471e Unify deprecated note field format (Jamil Lambert, PhD)

Pull request description:

  Following the suggestion in Issue #3306 all the deprecated note fields have been changed to be lower case and in the format "use `abc` instead".

ACKs for top commit:
  tcharding:
    ACK 88b53a471e
  apoelstra:
    ACK 88b53a471e successfully ran local tests

Tree-SHA512: 5c20eda7140f37ce78eb58dfdf03ecc11a67fcb10f294d860e81eaaee696e3a4209516017a9885cef9bfff1aa69b845534d139578b674933770fa24d59e4275f
2024-10-16 02:10:58 +00:00
Jamil Lambert, PhD 88b53a471e
Unify deprecated note field format
All the deprecated note fields have been changed to be lower case and in
the format "use `a` instead".
2024-10-15 15:16:01 +01:00
Jamil Lambert, PhD fbc7aa7fd5
Remove unnecessary lifetimes
New lint warnings from recent nightly toolchain show some explicit
lifetimes that can be omitted.

The unnecessary lifetimes have been removed.
2024-10-15 14:02:56 +01:00
Tobin C. Harding e68da281ff
Warn on future deprecations
We use `TBD` in our `deprecated` string and it was discovered that there
is an exception on this string so as not to warn because it is used
internally by the Rust language. However there is a special lint to
enable warnings, lets use it.

Add `#![warn(deprecated_in_future)]` to the coding conventions section
of all crates except `fuzz`.
2024-10-15 07:56:06 +11:00
Fmt Bot f1733309e0 2024-10-13 automated rustfmt nightly 2024-10-13 01:20:28 +00:00
merge-script 27f6f17974
Merge rust-bitcoin/rust-bitcoin#3430: Add checked div by weight to amount
a0c58a4a8b Add checked weight division to Amount (yancy)
8def40a991 Add assertions to checked_weight_mul test (yancy)
16ce70d3a6 Add div_by_weight test to fee_rate (yancy)

Pull request description:

  Adds the checked variant of `amount / weight`.  I also added a test to the non-checked version for comparison so the reviewer knows they compute the same way (integer division rounded down).

  Also added assertion to `checked_weight_mul test` showing the results are rounded up.

ACKs for top commit:
  tcharding:
    ACK a0c58a4a8b
  apoelstra:
    ACK a0c58a4a8b successfully ran local tests

Tree-SHA512: cf14123ed261d100e3261a720c26f8c10368f05225e32eaa246f25ab766d20515db5feb98335d4e3e08a8146a70db65ff64670da3f75e7764e8f86ef534d2663
2024-10-10 18:19:16 +00:00
yancy a0c58a4a8b Add checked weight division to Amount 2024-10-09 09:30:09 -05:00
merge-script e8a3c1f01b
Merge rust-bitcoin/rust-bitcoin#3117: Release tracking PR: `bitcoin-units 0.2.0`
07a529a132 Bump version of bitcoin-units to 0.2.0 (Tobin C. Harding)
148711a4c6 units: Use double ## in changelog entries (Tobin C. Harding)
80e600ba0c units: Copy 0.1.2 release notes (Tobin C. Harding)

Pull request description:

  In preparation for releasing `units v0.2.0` bump the version number, add a changelog entry, update the lock files, and depend on the new version in all crates that depend on `units`.

  Close: #3095

ACKs for top commit:
  apoelstra:
    ACK 07a529a132 successfully ran local tests

Tree-SHA512: 98a75d485ded6225551a5fc4b4a14d8efecc76911a720f959044cdd62781024a8787f258f171ed297705f5ab470f9a88a81ad5d255c9e03c1e22857615ad2e6d
2024-10-01 22:51:05 +00:00
yancy 8def40a991 Add assertions to checked_weight_mul test 2024-09-30 19:05:18 -05:00