Struct ln_types::amount::Amount [−][src]
pub struct Amount(_);Expand description
Number of millisatoshis.
This type represents a number of millisatoshis (thousands of satoshi) which is the base unit of the lightning network. It provides ordinary arithmetic and conversion methods.
Invariants
This type guarantees that the amount stays less than or equal to 21 million bitcoins.
However unsafe code must not rely on this, at least for now.
This implies that arithmetic operations always panic on overflow.
Display implementation
To avoid confusion, the amount is displayed with msat suffix - e.g. 42 msat.
No other representations are supported yet, feel free to contribute!
Implementations
Constructs the amount from raw millisatosis.
The value is directly converted with an overflow check.
Errors
This method returns an error if the amount exceeds Bitcoin supply cap
Constructs the amount from raw satosis.
The value is converted with an overflow check.
Errors
This method returns an error if the amount exceeds Bitcoin supply cap
Attempts to convert the value to raw satoshis.
Errors
This method returns an error if the number of millisatoshis isn’t rounded to thousands.
Converts to satoshis rounding down.
Converts to satoshis rounding up.
Converts to satoshis rounding.
Trait Implementations
Panics on overflow
Displays the amount followed by denomination msat.
The value is deserialized as u64 msats.
Deserialize this value from the given Serde deserializer. Read more
Displays the amount followed by denomination msat.
Performs the /= operation. Read more
Retrieved as i64 msats with range check
Accepts an unsigned integer up to 21 000 000 BTC
The amount may optionally be followed by denomination msat.
Panics on overflow
Panics on overflow
Writes human-readable description of the type to the writer. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Performs the %= operation. Read more
The value is serialized as u64 msats.
Panics on overflow
Stored as i64 msats
Accepts an unsigned integer up to 21 000 000 BTC
The amount may optionally be followed by denomination msat.
Accepts an unsigned integer up to 21 000 000 BTC
The amount may optionally be followed by denomination msat.
Accepts an unsigned integer up to 21 000 000 BTC
The amount may optionally be followed by denomination msat.
Logs msats using emit_u64
Auto Trait Implementations
impl RefUnwindSafe for Amount
impl UnwindSafe for Amount
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns a reference to self as a ToSql trait object.
