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 |
||
---|---|---|
.. | ||
contrib | ||
src | ||
tests | ||
CHANGELOG.md | ||
Cargo.toml | ||
README.md |
README.md
Bitcoin Units
This crate provides basic Bitcoin numeric units such as Amount
.
Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on Rust 1.63.0.
Licensing
The code in this project is licensed under the Creative Commons CC0 1.0 Universal license. We use the SPDX license list and SPDX IDs.