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,
requested_amount: Amount,
) -> Result<(), ValidateIssuanceError> { ... }
fn validate_signing_key(
&self,
offer: &Offer,
) -> Result<(), CheckSignatureError> { ... }
}Expand description
Extension trait for the Bolt12Invoice type
Provided Methods§
fn payment_hash(&self) -> PaymentHash
Sourcefn get_payment_amount(
&self,
user_amount: Option<Amount>,
) -> Result<Amount, CheckAmountError>
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.
fn bytes(&self) -> Vec<u8> ⓘ
fn from_bytes(bytes: &[u8]) -> Result<Bolt12Invoice, Bolt12ParseError>
fn from_str(s: &str) -> Result<Bolt12Invoice, Bolt12ParseError>
Sourcefn check_signature(&self) -> Result<(), CheckSignatureError>
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.
Sourcefn validate_issuance(
&self,
offer: &Offer,
requested_amount: Amount,
) -> Result<(), ValidateIssuanceError>
fn validate_issuance( &self, offer: &Offer, requested_amount: Amount, ) -> Result<(), ValidateIssuanceError>
Checks that the invoice was issued for offer and that it commits to
requested_amount, the amount that was asked for when fetching it.
This method should be called before paying any invoice fetched from an offer.
Sourcefn validate_signing_key(&self, offer: &Offer) -> Result<(), CheckSignatureError>
fn validate_signing_key(&self, offer: &Offer) -> Result<(), CheckSignatureError>
Checks the invoice signing pubkey is the same as the offer’s, then verifies the signature.
This only binds the invoice to the offer’s issuer, not to what we requested;
use Bolt12InvoiceExt::validate_issuance before paying.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".