diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index 2119f488d..463982895 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -77,9 +77,9 @@ impl SignedAmount { /// Exactly one satoshi. pub const ONE_SAT: Self = SignedAmount::from_sat_unchecked(1); /// Exactly one bitcoin. - pub const ONE_BTC: Self = SignedAmount::from_int_btc_const(1); + pub const ONE_BTC: Self = SignedAmount::from_btc_i16(1); /// Exactly fifty bitcoin. - pub const FIFTY_BTC: Self = SignedAmount::from_int_btc_const(50); + pub const FIFTY_BTC: Self = SignedAmount::from_btc_i16(50); /// The maximum value allowed as an amount. Useful for sanity checking. pub const MAX_MONEY: Self = SignedAmount::from_sat_unchecked(21_000_000 * 100_000_000); /// The minimum value of an amount. @@ -136,13 +136,13 @@ impl SignedAmount { /// Converts from a value expressing a whole number of bitcoin to a [`SignedAmount`]. #[allow(clippy::missing_panics_doc)] pub fn from_int_btc>(whole_bitcoin: T) -> SignedAmount { - SignedAmount::from_int_btc_const(whole_bitcoin.into()) + SignedAmount::from_btc_i16(whole_bitcoin.into()) } /// Converts from a value expressing a whole number of bitcoin to a [`SignedAmount`] /// in const context. #[allow(clippy::missing_panics_doc)] - pub const fn from_int_btc_const(whole_bitcoin: i16) -> SignedAmount { + pub const fn from_btc_i16(whole_bitcoin: i16) -> SignedAmount { let btc = whole_bitcoin as i64; // Can't call `into` in const context. let sats = btc * 100_000_000; diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs index 5fc495588..60676f605 100644 --- a/units/src/amount/tests.rs +++ b/units/src/amount/tests.rs @@ -102,8 +102,10 @@ fn from_str_zero_without_denomination() { #[test] fn from_int_btc() { - let amt = Amount::from_int_btc_const(2); + let amt = Amount::from_btc_u16(2); assert_eq!(sat(200_000_000), amt); + let amt = SignedAmount::from_btc_i16(-2); + assert_eq!(ssat(-200_000_000), amt); } #[test] diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index ab1abb9c3..9f6215d08 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -75,9 +75,9 @@ impl Amount { /// Exactly one satoshi. pub const ONE_SAT: Self = Amount::from_sat_unchecked(1); /// Exactly one bitcoin. - pub const ONE_BTC: Self = Amount::from_int_btc_const(1); + pub const ONE_BTC: Self = Amount::from_btc_u16(1); /// Exactly fifty bitcoin. - pub const FIFTY_BTC: Self = Amount::from_int_btc_const(50); + pub const FIFTY_BTC: Self = Amount::from_btc_u16(50); /// The maximum value allowed as an amount. Useful for sanity checking. pub const MAX_MONEY: Self = Amount::from_sat_unchecked(21_000_000 * 100_000_000); /// The minimum value of an amount. @@ -134,13 +134,13 @@ impl Amount { /// Converts from a value expressing a whole number of bitcoin to an [`Amount`]. #[allow(clippy::missing_panics_doc)] pub fn from_int_btc>(whole_bitcoin: T) -> Amount { - Amount::from_int_btc_const(whole_bitcoin.into()) + Amount::from_btc_u16(whole_bitcoin.into()) } /// Converts from a value expressing a whole number of bitcoin to an [`Amount`] /// in const context. #[allow(clippy::missing_panics_doc)] - pub const fn from_int_btc_const(whole_bitcoin: u16) -> Amount { + pub const fn from_btc_u16(whole_bitcoin: u16) -> Amount { let btc = whole_bitcoin as u64; // Can't call `into` in const context. let sats = btc * 100_000_000;