Struct Offer
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§
§impl Offer
impl Offer
pub 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.
pub 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
.
pub fn amount(&self) -> Option<&Amount>
pub fn amount(&self) -> Option<&Amount>
The minimum amount required for a successful payment of a single item.
pub fn description(&self) -> PrintableString<'_>
pub fn description(&self) -> 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.
pub fn offer_features(&self) -> &Features<OfferContext>
pub fn offer_features(&self) -> &Features<OfferContext>
Features pertaining to the offer.
pub 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.
pub 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.
pub 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.
pub fn supported_quantity(&self) -> Quantity
pub fn supported_quantity(&self) -> Quantity
The quantity of items supported.
pub fn signing_pubkey(&self) -> PublicKey
pub fn signing_pubkey(&self) -> PublicKey
The public key used by the recipient to sign invoices.
pub 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.
pub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Whether the offer has expired.
pub 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.
pub fn expects_quantity(&self) -> bool
pub fn expects_quantity(&self) -> bool
Returns whether a quantity is expected in an InvoiceRequest
for the offer.
pub fn request_invoice_deriving_payer_id<'a, 'b, ES, T>(
&'a self,
expanded_key: &ExpandedKey,
entropy_source: ES,
secp_ctx: &'b Secp256k1<T>,
payment_id: PaymentId,
) -> Result<InvoiceRequestBuilder<'a, 'b, DerivedPayerId, T>, Bolt12SemanticError>
pub fn request_invoice_deriving_payer_id<'a, 'b, ES, T>( &'a self, expanded_key: &ExpandedKey, entropy_source: ES, secp_ctx: &'b Secp256k1<T>, payment_id: PaymentId, ) -> Result<InvoiceRequestBuilder<'a, 'b, DerivedPayerId, T>, Bolt12SemanticError>
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.
This is not exported to bindings users as builder patterns don’t map outside of move semantics.
pub fn request_invoice_deriving_metadata<ES>(
&self,
payer_id: PublicKey,
expanded_key: &ExpandedKey,
entropy_source: ES,
payment_id: PaymentId,
) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>
pub fn request_invoice_deriving_metadata<ES>( &self, payer_id: PublicKey, expanded_key: &ExpandedKey, entropy_source: ES, payment_id: PaymentId, ) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>
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.
This is not exported to bindings users as builder patterns don’t map outside of move semantics.
pub fn request_invoice(
&self,
metadata: Vec<u8>,
payer_id: PublicKey,
) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>
pub fn request_invoice( &self, metadata: Vec<u8>, payer_id: PublicKey, ) -> Result<InvoiceRequestBuilder<'_, '_, ExplicitPayerId, SignOnly>, Bolt12SemanticError>
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.
This is not exported to bindings users as builder patterns don’t map outside of move semantics.
Trait Implementations§
§impl Writeable for Offer
impl Writeable for Offer
Auto Trait Implementations§
impl Freeze for Offer
impl RefUnwindSafe for Offer
impl Send for Offer
impl Sync for Offer
impl Unpin for Offer
impl UnwindSafe for Offer
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<T> Base32Len for T
impl<T> Base32Len for T
§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckBase32<Vec<u5>> for T
impl<T> CheckBase32<Vec<u5>> for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> ToBase32 for T
impl<T> ToBase32 for T
§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)