pub struct CkbInvoice {
pub currency: Currency,
pub amount: Option<u128>,
pub signature: Option<InvoiceSignature>,
pub data: InvoiceData,
}Expand description
Represents a syntactically and semantically correct Fiber invoice.
There are three ways to construct a CkbInvoice:
- using
CkbInvoiceBuilder - using
str::parse::<CkbInvoice>(&str)(seeCkbInvoice::from_str)
Fields§
§currency: CurrencyThe currency of the invoice.
amount: Option<u128>The amount of the invoice.
signature: Option<InvoiceSignature>The signature of the invoice.
data: InvoiceDataThe invoice data, including the payment hash, timestamp and other attributes.
Implementations§
Source§impl CkbInvoice
impl CkbInvoice
Sourcepub fn check_signature(&self) -> Result<(), InvoiceError>
pub fn check_signature(&self) -> Result<(), InvoiceError>
Check that the invoice is signed correctly and that key recovery works.
Sourcepub fn recover_payee_pub_key(&self) -> Result<PublicKey, Error>
pub fn recover_payee_pub_key(&self) -> Result<PublicKey, Error>
Recovers the public key used for signing the invoice from the recoverable signature.
Sourcepub fn payee_pub_key(&self) -> Option<&PublicKey>
pub fn payee_pub_key(&self) -> Option<&PublicKey>
Returns the payee public key if set in the invoice attributes.
Sourcepub fn payment_hash(&self) -> &Hash256
pub fn payment_hash(&self) -> &Hash256
Returns the payment hash of the invoice.
Sourcepub fn udt_type_script(&self) -> Option<&PackedScript>
pub fn udt_type_script(&self) -> Option<&PackedScript>
Returns the UDT type script if set in the invoice attributes.
Sourcepub fn expiry_time(&self) -> Option<&Duration>
pub fn expiry_time(&self) -> Option<&Duration>
Returns the expiry time if set in the invoice attributes.
Sourcepub fn description(&self) -> Option<&String>
pub fn description(&self) -> Option<&String>
Returns the description if set in the invoice attributes.
Sourcepub fn final_tlc_minimum_expiry_delta(&self) -> Option<&u64>
pub fn final_tlc_minimum_expiry_delta(&self) -> Option<&u64>
Returns the final TLC minimum expiry delta if set in the invoice attributes.
Sourcepub fn final_tlc_minimum_expiry_delta_or_default(&self) -> u64
pub fn final_tlc_minimum_expiry_delta_or_default(&self) -> u64
Returns the effective final TLC minimum expiry delta.
Uses DEFAULT_FINAL_TLC_EXPIRY_DELTA when the invoice omits the
corresponding attribute.
Sourcepub fn fallback_address(&self) -> Option<&String>
pub fn fallback_address(&self) -> Option<&String>
Returns the fallback address if set in the invoice attributes.
Sourcepub fn hash_algorithm(&self) -> Option<&HashAlgorithm>
pub fn hash_algorithm(&self) -> Option<&HashAlgorithm>
Returns the hash algorithm if set in the invoice attributes.
Sourcepub fn payment_secret(&self) -> Option<&Hash256>
pub fn payment_secret(&self) -> Option<&Hash256>
Returns the payment secret if set in the invoice attributes.
Sourcepub fn allow_trampoline_routing(&self) -> bool
pub fn allow_trampoline_routing(&self) -> bool
Returns whether the invoice allows trampoline routing.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns whether the invoice has expired based on the current time.
Sourcepub fn is_tlc_expire_too_soon(&self, tlc_expiry: u64) -> bool
pub fn is_tlc_expire_too_soon(&self, tlc_expiry: u64) -> bool
Returns whether the TLC expiry is too soon for the given invoice.
Sourcepub fn update_signature<F>(
&mut self,
sign_function: F,
) -> Result<(), InvoiceError>
pub fn update_signature<F>( &mut self, sign_function: F, ) -> Result<(), InvoiceError>
Updates the invoice signature using the provided signing function.
Source§impl CkbInvoice
impl CkbInvoice
Sourcepub fn from_str_allowing_unsigned(s: &str) -> Result<Self, InvoiceError>
pub fn from_str_allowing_unsigned(s: &str) -> Result<Self, InvoiceError>
Parses an invoice from its bech32m string representation, accepting both signed and unsigned invoices.
Most callers should use FromStr::from_str, which additionally requires
the invoice to be signed. Only use this method in contexts where an
unsigned invoice is legitimately expected (for example, decoding an
invoice purely for inspection).
Trait Implementations§
Source§impl Clone for CkbInvoice
impl Clone for CkbInvoice
Source§fn clone(&self) -> CkbInvoice
fn clone(&self) -> CkbInvoice
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more