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 BlindedPath
s, 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) -> &[BlindedPath]
pub fn paths(&self) -> &[BlindedPath]
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 signing_pubkey(&self) -> Option<PublicKey>
pub fn signing_pubkey(&self) -> Option<PublicKey>
The public key used by the recipient to sign invoices.
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_deriving_payer_id<'a, 'b, ES: Deref, T: Signing>(
&'a self,
expanded_key: &ExpandedKey,
entropy_source: ES,
secp_ctx: &'b Secp256k1<T>,
payment_id: PaymentId
) -> Result<InvoiceRequestBuilder<'a, 'b, DerivedPayerId, T>, Bolt12SemanticError>where
ES::Target: EntropySource,
Available on non-c_bindings
only.
pub fn request_invoice_deriving_payer_id<'a, 'b, ES: Deref, T: Signing>(
&'a self,
expanded_key: &ExpandedKey,
entropy_source: ES,
secp_ctx: &'b Secp256k1<T>,
payment_id: PaymentId
) -> Result<InvoiceRequestBuilder<'a, 'b, DerivedPayerId, T>, Bolt12SemanticError>where
ES::Target: EntropySource,
c_bindings
only.Similar to Offer::request_invoice
except it:
- derives the
InvoiceRequest::payer_id
such that a different key can be used for each request, - sets
InvoiceRequest::payer_metadata
whenInvoiceRequestBuilder::build
is called such that it can be used byBolt12Invoice::verify
to determine if the invoice was requested using a baseExpandedKey
from which the payer id was derived, and - includes the
PaymentId
encrypted inInvoiceRequest::payer_metadata
so that it can be used when sending the payment for the requested invoice.
Useful to protect the sender’s privacy.
sourcepub fn request_invoice_deriving_metadata<ES: Deref>(
&self,
payer_id: PublicKey,
expanded_key: &ExpandedKey,
entropy_source: ES,
payment_id: PaymentId
) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>where
ES::Target: EntropySource,
Available on non-c_bindings
only.
pub fn request_invoice_deriving_metadata<ES: Deref>(
&self,
payer_id: PublicKey,
expanded_key: &ExpandedKey,
entropy_source: ES,
payment_id: PaymentId
) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>where
ES::Target: EntropySource,
c_bindings
only.Similar to Offer::request_invoice_deriving_payer_id
except uses payer_id
for the
InvoiceRequest::payer_id
instead of deriving a different key for each request.
Useful for recurring payments using the same payer_id
with different invoices.
sourcepub fn request_invoice(
&self,
metadata: Vec<u8>,
payer_id: PublicKey
) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>
Available on non-c_bindings
only.
pub fn request_invoice( &self, metadata: Vec<u8>, payer_id: PublicKey ) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>
c_bindings
only.Creates an InvoiceRequestBuilder
for the offer with the given metadata
and payer_id
,
which will be reflected in the Bolt12Invoice
response.
The metadata
is useful for including information about the derivation of payer_id
such
that invoice response handling can be stateless. Also serves as payer-provided entropy while
hashing in the signature calculation.
This should not leak any information such as by using a simple BIP-32 derivation path. Otherwise, payments may be correlated.
Errors if the offer contains unknown required features.