pub struct Amount(/* private fields */);Expand description
An amount of Bitcoin
Sadly, because lightning uses “milli-satoshis” we cannot directly use rust-bitcon’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 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) -> Self
pub const fn from_milli_sats(msats: u64) -> Self
Constructs a new Amount for the given number of milli-satoshis.
Sourcepub const fn from_sats(sats: u64) -> Self
pub const fn from_sats(sats: u64) -> Self
Constructs a new Amount for the given number of satoshis.
Sourcepub fn saturating_add(self, rhs: Amount) -> Amount
pub fn saturating_add(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 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
Mutably borrows from an owned value. Read more