pub struct Offer { /* private fields */ }Expand description
An Offer is a potentially long-lived proposal for payment of a good or service.
An offer is a precursor to an InvoiceRequest. A merchant publishes an offer from which a
customer may request an Bolt12Invoice for a specific quantity and using an amount sufficient
to cover that quantity (i.e., at least quantity * amount). See Offer::amount.
Offers may be denominated in currency other than bitcoin but are ultimately paid using the latter.
Through the use of BlindedMessagePaths, offers provide recipient privacy.
Implementations§
Source§impl Offer
impl Offer
Sourcepub fn chains(&self) -> Vec<ChainHash>
pub fn chains(&self) -> Vec<ChainHash>
The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) for the selected chain.
Sourcepub fn metadata(&self) -> Option<&Vec<u8>>
pub fn metadata(&self) -> Option<&Vec<u8>>
Opaque bytes set by the originator. Useful for authentication and validating fields since it
is reflected in invoice_request messages along with all the other fields from the offer.
Sourcepub fn amount(&self) -> Option<Amount>
pub fn amount(&self) -> Option<Amount>
The minimum amount required for a successful payment of a single item.
Sourcepub fn description(&self) -> Option<PrintableString<'_>>
pub fn description(&self) -> Option<PrintableString<'_>>
A complete description of the purpose of the payment. Intended to be displayed to the user but with the caveat that it has not been verified in any way.
Sourcepub fn offer_features(&self) -> &OfferFeatures
pub fn offer_features(&self) -> &OfferFeatures
Features pertaining to the offer.
Sourcepub fn absolute_expiry(&self) -> Option<Duration>
pub fn absolute_expiry(&self) -> Option<Duration>
Duration since the Unix epoch when an invoice should no longer be requested.
If None, the offer does not expire.
Sourcepub fn issuer(&self) -> Option<PrintableString<'_>>
pub fn issuer(&self) -> Option<PrintableString<'_>>
The issuer of the offer, possibly beginning with user@domain or domain. Intended to be
displayed to the user but with the caveat that it has not been verified in any way.
Sourcepub fn paths(&self) -> &[BlindedMessagePath]
pub fn paths(&self) -> &[BlindedMessagePath]
Paths to the recipient originating from publicly reachable nodes. Blinded paths provide recipient privacy by obfuscating its node id.
Sourcepub fn supported_quantity(&self) -> Quantity
pub fn supported_quantity(&self) -> Quantity
The quantity of items supported.
Sourcepub fn issuer_signing_pubkey(&self) -> Option<PublicKey>
pub fn issuer_signing_pubkey(&self) -> Option<PublicKey>
The public key corresponding to the key used by the recipient to sign invoices.
- If
Offer::pathsis empty, MUST beSomeand contain the recipient’s node id for sending anInvoiceRequest. - If
Offer::pathsis not empty, MAY beSomeand contain a transient id. - If
None, the signing pubkey will be the final blinded node id from theBlindedMessagePathinOffer::pathsused to send theInvoiceRequest.
See also Bolt12Invoice::signing_pubkey.
Sourcepub fn supports_chain(&self, chain: ChainHash) -> bool
pub fn supports_chain(&self, chain: ChainHash) -> bool
Returns whether the given chain is supported by the offer.
Sourcepub fn is_expired(&self) -> bool
Available on crate feature std only.
pub fn is_expired(&self) -> bool
std only.Whether the offer has expired.
Sourcepub fn is_expired_no_std(&self, duration_since_epoch: Duration) -> bool
pub fn is_expired_no_std(&self, duration_since_epoch: Duration) -> bool
Whether the offer has expired given the duration since the Unix epoch.
Sourcepub fn is_valid_quantity(&self, quantity: u64) -> bool
pub fn is_valid_quantity(&self, quantity: u64) -> bool
Returns whether the given quantity is valid for the offer.
Sourcepub fn expects_quantity(&self) -> bool
pub fn expects_quantity(&self) -> bool
Returns whether a quantity is expected in an InvoiceRequest for the offer.
Source§impl Offer
impl Offer
Sourcepub fn request_invoice<'a, 'b, T: Signing>(
&'a self,
expanded_key: &ExpandedKey,
nonce: Nonce,
secp_ctx: &'b Secp256k1<T>,
payment_id: PaymentId,
) -> Result<InvoiceRequestBuilder<'a, 'b, T>, Bolt12SemanticError>
Available on non-c_bindings only.
pub fn request_invoice<'a, 'b, T: Signing>( &'a self, expanded_key: &ExpandedKey, nonce: Nonce, secp_ctx: &'b Secp256k1<T>, payment_id: PaymentId, ) -> Result<InvoiceRequestBuilder<'a, 'b, T>, Bolt12SemanticError>
c_bindings only.Creates an InvoiceRequestBuilder for the offer, which
- derives the
InvoiceRequest::payer_signing_pubkeysuch that a different key can be used for each request in order to protect the sender’s privacy, - sets
InvoiceRequest::payer_metadatawhenInvoiceRequestBuilder::build_and_signis called such that it can be used byBolt12Invoice::verify_using_metadatato determine if the invoice was requested using a baseExpandedKeyfrom which the payer id was derived, and - includes the
PaymentIdencrypted inInvoiceRequest::payer_metadataso that it can be used when sending the payment for the requested invoice.
Errors if the offer contains unknown required features.