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: ACKac74ed2144
apoelstra: ACK ac74ed2144e785fef7c395388a4fb7fb394e833e; successfully ran local tests; nice. Simple and obviously an improvement Tree-SHA512: 4003a2f3b34e03330c57125622cab5e55a235b1a610dda622035c071bc5530811e275c2e25f40e1309cecf1c3bef35070ae690fa57fdf3e2c1b5c3f75ca5d29e
This commit is contained in:
commit
ec37c28fad
|
@ -108,7 +108,7 @@ impl SignedAmount {
|
|||
pub fn from_str_in(s: &str, denom: Denomination) -> Result<SignedAmount, ParseAmountError> {
|
||||
match parse_signed_to_satoshi(s, denom).map_err(|error| error.convert(true))? {
|
||||
// (negative, amount)
|
||||
(false, sat) if sat > i64::MAX as u64 => Err(ParseAmountError(
|
||||
(false, sat) if sat > SignedAmount::MAX.to_sat() as u64 => Err(ParseAmountError(
|
||||
ParseAmountErrorInner::OutOfRange(OutOfRangeError::too_big(true)),
|
||||
)),
|
||||
(false, sat) => Ok(SignedAmount(sat as i64)),
|
||||
|
|
Loading…
Reference in New Issue