Skip to main content

Offer

Struct Offer 

Source
pub struct Offer(pub Offer);
Expand description

A Lightning BOLT12 offer.

§Examples

To start, we have just about the shortest possible offer: an unblinded NodePk, at just 64 bytes long.

"lno1pgqpvggzfyqv8gg09k4q35tc5mkmzr7re2nm20gw5qp5d08r3w5s6zzu4t5q"

Offer {
    bytes: [ .. ],
    contents: OfferContents {
        chains: None,
        metadata: None,
        amount: None,
        description: "",
        features: [],
        absolute_expiry: None,
        issuer: None,
        paths: None,
        supported_quantity: One,
        payee_node_pk: 024900c3a10f2daa08d178a6edb10fc3caa7b53d0ea00346bce38ba90d085caae8,
    },
},

Here’s an offer with an amount, description, and “issuer” (payee name), at 142 bytes long.

"lno1pqzqzhhncq9pwargd9ejq6tnyp6xsefqv3jhxcmjd9c8g6t0dcfpyargd9ejq6tnyp6xsefqd9ehxat9wgtzzqjfqrp6zred4gydz79xakcsls72576n6r4qqdrtecut4yxssh92aq"


Offer {
    bytes: [ .. ],
    contents: OfferContents {
        chains: None,
        metadata: None,
        amount: Some( Bitcoin { amount_msats: 23000000 },),
        description: "this is the description",
        features: [],
        absolute_expiry: None,
        issuer: Some("this is the issuer"),
        paths: None,
        supported_quantity: One,
        payee_node_pk: 024900c3a10f2daa08d178a6edb10fc3caa7b53d0ea00346bce38ba90d085caae8,
    },
},

And that same offer but with a blinded path, now 500 bytes. Notice that the payee_node_pk is different (blinded).

"lno1qsgp3atwlvef5dfjngmladyyruuwvzqyq9008sq2za6xs6tnyp5hxgr5dpjjqer9wd3hy6tsw35k7mssesp8gcupm5mqgczgk58nxcjvs9yrg9390v8cc8jkyzq67j8x4gzkcrczfmv9cujazf9ws6jkfs9dld2ach6l9v32c9n6jkskgw5t2xp9zkuqyq4yvhz2yelft86qvnqppkt65623cs2dxmhm3mtqy2s6r5njdkcmrsqrxfs0vzt3z9635m89gqtzka8cfajtkdd3vknawyzq54hywm5ktllf7fl2ykvazfgfntp3qa7ljl0qgt2vkagzd8cpq0nctp5aqxtug2m8xhrmhd7l06vzy34vfflvrwvfyrngmfnqqyrrkfdzg229nuy2le0de6xfk7u6zgf8g6rfwvsxjueqw35x2grfwdeh2etjzcssxjqh6kmxxv3qxp9f8srkptd7xyzfjtfpz2usaxlq50vgxpm6u2n6"

Offer {
    bytes: [ .. ],
    contents: OfferContents {
        chains: None,
        metadata: Some("18f56efb329a35329a37feb4841f38e6"),
        amount: Some( Bitcoin { amount_msats: 23000000 },),
        description: "this is the description",
        features: [],
        absolute_expiry: None,
        issuer: Some("this is the issuer"),
        paths: Some([
            BlindedPath {
                introduction_node_id: 0f6c05aae648af8120561e8c0f7b25163448814c62330fb548600436dd816374aaec6016fae2ab91d670b639dcc8846da8fcdfbf4ea19050f8fd262df2d0dc21,
                blinding_point: b8152518b5a843165aa967c12ab2f2f5c55db5df0a4c566ae84a125d725cd84eb0dbcb7ebe7404bfc4eefb70e34458b78566e28e28aeaabc4d344291b8506bcd,
                blinded_hops: [
                    BlindedHop {
                        blinded_node_id: 1c1bdb26271d1a2a02d68efb6ed314c45169aa970d014c06f459e967a2c465a4cc876a78e5774826a420981dc49f35d4105da4ecd08d1f1429ad8acb09a8cfd6,
                        encrypted_payload: [ .. ],
                    },
                    BlindedHop {
                        blinded_node_id: 66da680e92981beca7c46a2482e9f77dbb7b5c73b6427c19d06958783e10f069467f3c9c418f044d1599b6a1237f5d2b866e08427f0ba0abc3cc38730a7d94ea,
                        encrypted_payload: [ .. ],
                    },
                ],
            },
        ]),
        supported_quantity: One,
        payee_node_pk: 034817d5b6633220304a93c0760adbe3104992d2112b90e9be0a3d883077ae2a7a,
    },
},

Tuple Fields§

§0: Offer

Implementations§

Source§

impl Offer

Source

pub fn id(&self) -> OfferId

Return the OfferId of this offer.

Source

pub fn as_bytes(&self) -> &[u8]

Return the serialized offer.

Source

pub fn supports_network(&self, network: Network) -> bool

Return true if this offer is payable on the given Network, e.g., mainnet, testnet, etc…

Source

pub fn payee(&self) -> Option<&str>

The self-reported payee name, if any. Ex: “satoshi@lexe.app”, “Satoshi”

Source

pub fn payee_node_pk(&self) -> Option<NodePk>

Returns the payee NodePk. Unlike LDK, we only return Some if this is a real pubkey and not a transient blinded pubkey.

Source

pub fn expires_at(&self) -> Option<TimestampMs>

The absolute expiration time of the offer, if any.

Source

pub fn is_expired(&self) -> bool

Returns true if the offer has an expiration and is expired.

Source

pub fn is_expired_at(&self, ts: TimestampMs) -> bool

Returns true if the offer has an expiration and its expiration is before the given timestamp.

Source

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

Returns the Bitcoin-denominated Amount, if any.

Source

pub fn fiat_amount(&self) -> Option<([u8; 3], u64)>

Returns the fiat-denominated amount, if any. Returns the fiat ISO4217 currency code along with the ISO4217 exponent amount (e.g., USD cents).

Source

pub fn is_fiat_denominated(&self) -> bool

Returns true if the offer has a required amount that is denominated in a fiat currency and not BTC.

Source

pub fn expects_quantity(&self) -> bool

Source

pub fn description(&self) -> Option<&str>

Returns the offer description, if any.

Source

pub fn matches_hrp_prefix(s: &str) -> bool

Returns true if the input string starts with a valid bech32 hrp prefix for a BOLT12 offer.

Source

pub fn preflight_routable_node( &self, network_graph: &ReadOnlyNetworkGraph<'_>, lsp_node_pk: &NodePk, ) -> Result<NodePk, Error>

Some node we can route to during preflight.

Trait Implementations§

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<(), Error>

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

impl<'de> Deserialize<'de> for Offer

Source§

fn deserialize<__D>( deserializer: __D, ) -> Result<Offer, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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 From<Offer> for Offer

Source§

fn from(value: Offer) -> Offer

Converts to this type from the input type.
Source§

impl FromStr for Offer

Source§

type Err = ParseError

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

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

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

impl PartialEq for Offer

Source§

fn eq(&self, other: &Offer) -> 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 Serialize for Offer
where Offer: Display,

Source§

fn serialize<__S>( &self, serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<Vec<u8>> for Offer

Source§

type Error = ParseError

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

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

Performs the conversion.
Source§

impl Eq for Offer

Source§

impl StructuralPartialEq 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 UnsafeUnpin 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<F, T, U> Apply<F, U> for T
where F: FnOnce(T) -> U,

Source§

fn apply(self, f: F) -> U

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<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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

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

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,