From ab12410ae87231d4bb8c0c2886f87cd2a2072aeb Mon Sep 17 00:00:00 2001 From: z8674558 Date: Wed, 15 Dec 2021 01:54:39 +0900 Subject: [PATCH] add MAX_MONEY public constant to Amount --- src/util/amount.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/amount.rs b/src/util/amount.rs index dc310c20..c4f94558 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -270,6 +270,8 @@ impl Amount { pub const ONE_SAT: Amount = Amount(1); /// Exactly one bitcoin. pub const ONE_BTC: Amount = Amount(100_000_000); + /// The maximum value allowed as an amount. Useful for sanity checking. + pub const MAX_MONEY: Amount = Amount(21_000_000 * 100_000_000); /// Create an [Amount] with satoshi precision and the given number of satoshis. pub fn from_sat(satoshi: u64) -> Amount { @@ -555,6 +557,8 @@ impl SignedAmount { pub const ONE_SAT: SignedAmount = SignedAmount(1); /// Exactly one bitcoin. pub const ONE_BTC: SignedAmount = SignedAmount(100_000_000); + /// The maximum value allowed as an amount. Useful for sanity checking. + pub const MAX_MONEY: SignedAmount = SignedAmount(21_000_000 * 100_000_000); /// Create an [SignedAmount] with satoshi precision and the given number of satoshis. pub fn from_sat(satoshi: i64) -> SignedAmount {