Skip to main content

Bolt12InvoiceExt

Trait Bolt12InvoiceExt 

Source
pub trait Bolt12InvoiceExt: Borrow<Bolt12Invoice> {
    // Provided methods
    fn payment_hash(&self) -> PaymentHash { ... }
    fn get_payment_amount(
        &self,
        user_amount: Option<Amount>,
    ) -> Result<Amount, CheckAmountError> { ... }
    fn bytes(&self) -> Vec<u8>  { ... }
    fn from_bytes(bytes: &[u8]) -> Result<Bolt12Invoice, Bolt12ParseError> { ... }
    fn from_str(s: &str) -> Result<Bolt12Invoice, Bolt12ParseError> { ... }
    fn check_signature(&self) -> Result<(), CheckSignatureError> { ... }
    fn validate_issuance(
        &self,
        offer: &Offer,
    ) -> Result<(), CheckSignatureError> { ... }
}
Expand description

Extension trait for the Bolt12Invoice type

Provided Methods§

Source

fn payment_hash(&self) -> PaymentHash

Source

fn get_payment_amount( &self, user_amount: Option<Amount>, ) -> Result<Amount, CheckAmountError>

Get the amount to be paid. It checks both user and invoice equality if both are provided, else it tries to return one of them, or returns an error if neither are provided.

Source

fn bytes(&self) -> Vec<u8>

Source

fn from_bytes(bytes: &[u8]) -> Result<Bolt12Invoice, Bolt12ParseError>

Source

fn from_str(s: &str) -> Result<Bolt12Invoice, Bolt12ParseError>

Source

fn check_signature(&self) -> Result<(), CheckSignatureError>

Checks the signature of the invoice against the signing pubkey

To be fully secure, the signing pubkey should also be checked against the offer’s signing pubkey. This is done in Bolt12InvoiceExt::validate_issuance.

Source

fn validate_issuance(&self, offer: &Offer) -> Result<(), CheckSignatureError>

Checks the invoice signing pubkey is the same as the offer’s, then verifies the signature.

This method should be called before paying any invoice fetched from an offer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§