rust-bitcoin-unsafe-fast/units/src
merge-script 0ca9fcfd0e
Merge rust-bitcoin/rust-bitcoin#4157: Enforce MAX_MONEY invariant in amount types
ab4ea7c13d Enforce the MAX_MONEY invariant in amount types (Tobin C. Harding)

Pull request description:

  Enforcing the `MAX_MONEY` invariant is quite involved because it means multiple things:

  - Constructing amounts is now fallible
  - Converting from unsigned to signed is now infallible
  - Taking the absolute value is now infallible
  - Integer overflow is eliminated in various places

  Details:
  - Update `from_sat` to check the invariant
  - Fix all docs including examples
  - Use the unchecked constructor in test code
  - Comment any other use of the unchecked constructor
  - Deprecate `unchecked_abs`
  - Fail serde (using the horrible string error variant)
  - Try not to use the unchecked constructor in rustdocs, no need to encourage unsuspecting users to use it.
  - Use `?` in rustdoc examples (required by Rust API guidlines)
  - Remove `TryFrom<Amount> for SignedAmount` because the conversion is now infallible. Add a `From` impl.
  - Fix the arbitrary impls
  - Maintain correct formatting
  - Remove private `check_max` function as its no longer needed

  Close #620

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

Tree-SHA512: bec963d8ea69e202f399cd19bca864b06f3e86323d376c2d2126d74093598f8bbbf19792b2327dba0862ef6f0201202778014a2be7a14991f02917d8ca312afb
2025-03-13 23:35:40 +00:00
..
amount Enforce the MAX_MONEY invariant in amount types 2025-03-13 09:07:14 +11:00
fee_rate units: replace a gazillion more macro calls with new macro 2025-02-25 20:31:45 +00:00
locktime Kill remaining mutants 2025-01-21 17:01:36 -06:00
block.rs 2025-01-12 automated rustfmt nightly 2025-01-12 01:23:13 +00:00
fee.rs Merge rust-bitcoin/rust-bitcoin#4157: Enforce MAX_MONEY invariant in amount types 2025-03-13 23:35:40 +00:00
internal_macros.rs units: extend op reference macro to handle generics and where clauses 2025-02-25 20:31:45 +00:00
lib.rs Rename timestamp module to time 2025-03-08 08:30:10 +11:00
parse.rs units: Improve code comment on macros 2025-02-28 08:47:11 +11:00
time.rs Rename timestamp module to time 2025-03-08 08:30:10 +11:00
weight.rs Merge rust-bitcoin/rust-bitcoin#4174: Improve weight 2025-03-06 15:58:59 +00:00