pub struct Invoice(pub Bolt11Invoice);Expand description
A BOLT 11 Lightning invoice. Serialized as a bech32-encoded string
(e.g. "lnbc1...").
Tuple Fields§
§0: Bolt11InvoiceImplementations§
Source§impl Invoice
impl Invoice
Sourcepub fn payment_hash(&self) -> PaymentHash
pub fn payment_hash(&self) -> PaymentHash
The invoice payment hash. The payer will receive the preimage to this hash upon successful payment, as proof-of-payment.
Sourcepub fn payment_secret(&self) -> PaymentSecret
pub fn payment_secret(&self) -> PaymentSecret
The invoice payment secret, used to authenticate the payer to the payee and tie MPP HTLCs together.
Sourcepub fn payment_id(&self) -> PaymentId
pub fn payment_id(&self) -> PaymentId
Lexe’s main identifier for this payment, which for BOLT11 invoice
payments is just the Invoice::payment_hash.
pub fn network(&self) -> Network
pub fn supports_network(&self, network: Network) -> bool
Sourcepub fn description_str(&self) -> Option<&str>
pub fn description_str(&self) -> Option<&str>
If the invoice contains a non-empty, inline description, then return that as a string. Otherwise return None.
Sourcepub fn description_hash(&self) -> Option<&[u8; 32]>
pub fn description_hash(&self) -> Option<&[u8; 32]>
If the invoice uses a description hash, return that. Otherwise return None.
Sourcepub fn amount(&self) -> Option<Amount>
pub fn amount(&self) -> Option<Amount>
Return the invoice’s requested amount, if present. An invoice may leave the final amount up to the payer, in which case this field will be None.
Sourcepub fn amount_sats(&self) -> Option<u64>
pub fn amount_sats(&self) -> Option<u64>
The invoice amount in satoshis, if included.
Sourcepub fn created_at(&self) -> Result<TimestampMs, Error>
pub fn created_at(&self) -> Result<TimestampMs, Error>
Get the invoice creation timestamp. Returns an error if the timestamp is several hundred million years in the future.
Sourcepub fn saturating_created_at(&self) -> TimestampMs
pub fn saturating_created_at(&self) -> TimestampMs
Get the invoice creation timestamp unconditionally.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if the invoice has expired.
Sourcepub fn is_expired_at(&self, ts: TimestampMs) -> bool
pub fn is_expired_at(&self, ts: TimestampMs) -> bool
Returns true if the invoice expires before the given timestamp.
Sourcepub fn expires_at(&self) -> Result<TimestampMs, Error>
pub fn expires_at(&self) -> Result<TimestampMs, Error>
Get the invoice expiration timestamp. Returns an error if the timestamp is several hundred million years in the future.
Sourcepub fn saturating_expires_at(&self) -> TimestampMs
pub fn saturating_expires_at(&self) -> TimestampMs
Get the invoice expiration timestamp unconditionally.
Sourcepub fn payee_node_pk(&self) -> NodePk
pub fn payee_node_pk(&self) -> NodePk
Get the invoice payee’s NodePk.
If the pubkey is not included directly in the invoice, we have to
ecrecover the pubkey, which is somewhat more expensive (~20-40 us).
Sourcepub fn min_final_cltv_expiry_delta_u32(&self) -> Result<u32, Error>
pub fn min_final_cltv_expiry_delta_u32(&self) -> Result<u32, Error>
Returns the invoice’s min_final_cltv_expiry_delta time, if present,
otherwise lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA.
Sourcepub fn onchain_fallbacks(&self) -> Vec<Address>
pub fn onchain_fallbacks(&self) -> Vec<Address>
BOLT11 Invoices can attach optional onchain addresses for a payee to use if the lightning payment is not feasible. This fn returns those addresses.
Sourcepub fn matches_hrp_prefix(s: &str) -> bool
pub fn matches_hrp_prefix(s: &str) -> bool
Returns true if the input string starts with a valid bech32 hrp prefix
for a BOLT11 invoice.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Invoice
impl<'de> Deserialize<'de> for Invoice
Source§fn deserialize<__D>(
deserializer: __D,
) -> Result<Invoice, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
deserializer: __D,
) -> Result<Invoice, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Invoice
impl Serialize for Invoice
Source§fn serialize<__S>(
&self,
serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Invoice
impl StructuralPartialEq for Invoice
Auto Trait Implementations§
impl Freeze for Invoice
impl RefUnwindSafe for Invoice
impl Send for Invoice
impl Sync for Invoice
impl Unpin for Invoice
impl UnsafeUnpin for Invoice
impl UnwindSafe for Invoice
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> 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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.