From ac74ed2144e785fef7c395388a4fb7fb394e833e Mon Sep 17 00:00:00 2001 From: yancy Date: Fri, 6 Dec 2024 09:19:56 -0600 Subject: [PATCH] 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. --- units/src/amount/signed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index 1af91950c..4237ba0bb 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -108,7 +108,7 @@ impl SignedAmount { pub fn from_str_in(s: &str, denom: Denomination) -> Result { 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)),