pub struct Amount(/* private fields */);Expand description
An amount of Bitcoin
Sadly, because lightning uses “milli-satoshis” we cannot directly use rust-bitcoin’s Amount
type.
In general, when displaying amounts to the user, you should use Self::sats_rounding_up.
Implementations§
Source§impl Amount
impl Amount
Sourcepub const fn milli_sats(&self) -> u64
pub const fn milli_sats(&self) -> u64
The amount in milli-satoshis
Sourcepub const fn sats(&self) -> Result<u64, ()>
pub const fn sats(&self) -> Result<u64, ()>
The amount in satoshis, if it is exactly a whole number of sats.
Sourcepub const fn sats_rounding_up(&self) -> u64
pub const fn sats_rounding_up(&self) -> u64
The amount in satoshis, rounding up to the next whole satoshi.
Sourcepub const fn from_milli_sats(msats: u64) -> Result<Self, ()>
pub const fn from_milli_sats(msats: u64) -> Result<Self, ()>
Constructs a new Amount for the given number of milli-satoshis.
Fails only if msats is greater than 21 million Bitcoin (in milli-satoshis).
Sourcepub const fn from_sats(sats: u64) -> Result<Self, ()>
pub const fn from_sats(sats: u64) -> Result<Self, ()>
Constructs a new Amount for the given number of satoshis.
Fails only if sats is greater than 21 million Bitcoin (in satoshis).
Sourcepub const fn saturating_add(self, rhs: Amount) -> Amount
pub const fn saturating_add(self, rhs: Amount) -> Amount
Sourcepub const fn saturating_sub(self, rhs: Amount) -> Amount
pub const fn saturating_sub(self, rhs: Amount) -> Amount
Sourcepub fn btc_decimal_rounding_up_to_sats(self) -> FormattedAmount
pub fn btc_decimal_rounding_up_to_sats(self) -> FormattedAmount
Returns an object that implements core::fmt::Display which writes out the amount, in
bitcoin, with a decimal point between the whole-bitcoin and partial-bitcoin amounts, with
any milli-satoshis rounded up to the next whole satoshi.
Trait Implementations§
Source§impl From<Amount> for Amount
impl From<Amount> for Amount
Source§fn from(amt: BitcoinAmount) -> Amount
fn from(amt: BitcoinAmount) -> Amount
Source§impl Ord for Amount
impl Ord for Amount
Source§impl PartialOrd for Amount
impl PartialOrd for Amount
impl Copy for Amount
impl Eq for Amount
impl StructuralPartialEq for Amount
Auto Trait Implementations§
impl Freeze for Amount
impl RefUnwindSafe for Amount
impl Send for Amount
impl Sync for Amount
impl Unpin for Amount
impl UnwindSafe for Amount
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.