Closed
Conversation
ff9e8c2 to
3be7af9
Compare
Pull Request Test Coverage Report for Build 12182293262Details
💛 - Coveralls |
3be7af9 to
55848c5
Compare
Contributor
Author
|
Hmm that's right, |
Member
|
The unwraps are ugly, perhaps we should add a |
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
88edcc7 to
39a834e
Compare
|
🚨 API BREAKING CHANGE DETECTED To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section. |
39a834e to
bc39367
Compare
bc39367 to
a77b1ac
Compare
apoelstra
added a commit
that referenced
this pull request
Dec 9, 2024
6950c0a 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 6950c0a apoelstra: ACK 6950c0a; successfully ran local tests Tree-SHA512: 03ebf39c47b19ba88d95235538039f28bfa29f4499618fab25c9b627684c348ed41caef682e8f0e01ca62cf9ced8a1183fe3ed861bffeb9609b09440ddfb1c92
Closed
Contributor
Author
|
closing. see: #3794 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft PR
The thrust of this PR is to limit
Amountconstructors to MAX_MONEY and return NONE if exceeded. In so doing, currently limitfrom_sats()as a prototype.TODOs
MAX_MONEYfrom_btc(),from_int_btc()from_int_btc_constfrom_str_infrom_str_with_denominationNext PR TODO:
closes #3691