Offer

Struct Offer 

Source
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

Source

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.

Source

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.

Source

pub fn amount(&self) -> Option<Amount>

The minimum amount required for a successful payment of a single item.

Source

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.

Source

pub fn offer_features(&self) -> &OfferFeatures

Features pertaining to the offer.

Source

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.

Source

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.

Source

pub fn paths(&self) -> &[BlindedMessagePath]

Paths to the recipient originating from publicly reachable nodes. Blinded paths provide recipient privacy by obfuscating its node id.

Source

pub fn supported_quantity(&self) -> Quantity

The quantity of items supported.

Source

pub fn issuer_signing_pubkey(&self) -> Option<PublicKey>

The public key corresponding to the key used by the recipient to sign invoices.

See also Bolt12Invoice::signing_pubkey.

Source

pub fn id(&self) -> OfferId

Returns the id of the offer.

Source

pub fn supports_chain(&self, chain: ChainHash) -> bool

Returns whether the given chain is supported by the offer.

Source

pub fn is_expired(&self) -> bool

Available on crate feature std only.

Whether the offer has expired.

Source

pub fn is_expired_no_std(&self, duration_since_epoch: Duration) -> bool

Whether the offer has expired given the duration since the Unix epoch.

Source

pub fn is_valid_quantity(&self, quantity: u64) -> bool

Returns whether the given quantity is valid for the offer.

Source

pub fn expects_quantity(&self) -> bool

Returns whether a quantity is expected in an InvoiceRequest for the offer.

Source§

impl Offer

Source

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>

Available on non-c_bindings only.

Creates an InvoiceRequestBuilder for the offer, which

Errors if the offer contains unknown required features.

Trait Implementations§

Source§

impl AsRef<[u8]> for Offer

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Offer

Source§

fn clone(&self) -> Offer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Offer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Offer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromStr for Offer

Source§

type Err = Bolt12ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Offer

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Offer

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Readable for Offer

Source§

fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError>

Reads a Self in from the given Read.
Source§

impl TryFrom<Vec<u8>> for Offer

Source§

type Error = Bolt12ParseError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Writeable for Offer

Source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Writes self out to the given Writer.
Source§

fn encode(&self) -> Vec<u8>

Writes self out to a Vec<u8>.
Source§

fn serialized_length(&self) -> usize

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length.
Source§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeReadable for T
where T: Readable,

Source§

fn read<R>(reader: &mut R) -> Result<Option<T>, DecodeError>
where R: Read,

Reads a Self in from the given Read.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.