Struct breez_sdk_core::lightning::offers::offer::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 BlindedPaths, offers provide recipient privacy.

Implementations§

§

impl Offer

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>>

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>

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

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>

Features pertaining to the offer.

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<'_>>

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]

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

The quantity of items supported.

pub fn signing_pubkey(&self) -> PublicKey

The public key used by the recipient to sign invoices.

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

Returns whether the given chain is supported by the offer.

pub fn is_expired(&self) -> bool

Whether the offer has expired.

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

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>
where ES: Deref, T: Signing, <ES as Deref>::Target: EntropySource,

Similar to Offer::request_invoice except it:

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>
where ES: Deref, <ES as Deref>::Target: EntropySource,

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>

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 AsRef<[u8]> for Offer

§

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

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

impl Clone for Offer

§

fn clone(&self) -> Offer

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Offer

§

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

Formats the value using the given formatter. Read more
§

impl Display for Offer

§

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

Formats the value using the given formatter. Read more
§

impl FromStr for Offer

§

type Err = Bolt12ParseError

The associated error which can be returned from parsing.
§

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

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

impl TryFrom<Vec<u8>> for Offer

§

type Error = Bolt12ParseError

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

fn try_from(bytes: Vec<u8>) -> Result<Offer, <Offer as TryFrom<Vec<u8>>>::Error>

Performs the conversion.
§

impl Writeable for Offer

§

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

Writes self out to the given Writer.
§

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

Writes self out to a Vec<u8>.
§

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.

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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

§

fn type_name(&self) -> &'static str

Gets the type name of self
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

§

impl<T> Base32Len for T
where T: AsRef<[u8]>,

§

fn base32_len(&self) -> usize

Calculate the base32 serialized length
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
§

impl<T> CheckBase32<Vec<u5>> for T
where T: AsRef<[u8]>,

§

type Err = Error

Error type if conversion fails
§

fn check_base32(self) -> Result<Vec<u5>, <T as CheckBase32<Vec<u5>>>::Err>

Check if all values are in range and return array-like struct of u5 values
source§

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<T> Downcast for T
where T: AsAny + ?Sized,

§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
§

impl<T> ToBase32 for T
where T: AsRef<[u8]>,

§

fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>
where W: WriteBase32,

Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate.
§

fn to_base32(&self) -> Vec<u5>

Convert Self to base32 vector
source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
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§

default 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> DartSafe for T