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 BlindedMessagePaths, 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) -> 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.
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) -> &[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.
pub fn supported_quantity(&self) -> Quantity
pub fn supported_quantity(&self) -> Quantity
The quantity of items supported.
pub 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.
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_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.
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.
§impl Offer
impl Offer
pub fn request_invoice<'a, 'b, T>(
&'a self,
expanded_key: &ExpandedKey,
nonce: Nonce,
secp_ctx: &'b Secp256k1<T>,
payment_id: PaymentId,
) -> Result<InvoiceRequestBuilder<'a, 'b, T>, Bolt12SemanticError>where
T: Signing,
pub fn request_invoice<'a, 'b, T>(
&'a self,
expanded_key: &ExpandedKey,
nonce: Nonce,
secp_ctx: &'b Secp256k1<T>,
payment_id: PaymentId,
) -> Result<InvoiceRequestBuilder<'a, 'b, T>, Bolt12SemanticError>where
T: Signing,
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.
Trait Implementations§
§impl Writeable for Offer
impl Writeable for Offer
impl Eq 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<T> AnyEq for T
impl<T> AnyEq for T
§impl<T> AnySync for T
impl<T> AnySync for T
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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> MaybeReadable for Twhere
T: Readable,
impl<T> MaybeReadable for Twhere
T: Readable,
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToBase32 for T
impl<T> ToBase32 for T
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)§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.