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: OfferImplementations§
Source§impl Offer
impl Offer
Sourcepub fn supports_network(&self, network: Network) -> bool
pub fn supports_network(&self, network: Network) -> bool
Return true if this offer is payable on the given Network,
e.g., mainnet, testnet, etc…
Sourcepub fn payee(&self) -> Option<&str>
pub fn payee(&self) -> Option<&str>
The self-reported payee name, if any. Ex: “satoshi@lexe.app”, “Satoshi”
Sourcepub fn payee_node_pk(&self) -> Option<NodePk>
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.
Sourcepub fn expires_at(&self) -> Option<TimestampMs>
pub fn expires_at(&self) -> Option<TimestampMs>
The absolute expiration time of the offer, if any.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if the offer has an expiration and is expired.
Sourcepub fn is_expired_at(&self, ts: TimestampMs) -> bool
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.
Sourcepub fn fiat_amount(&self) -> Option<([u8; 3], u64)>
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).
Sourcepub fn is_fiat_denominated(&self) -> bool
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.
pub fn expects_quantity(&self) -> bool
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Returns the offer description, if any.
Sourcepub fn matches_hrp_prefix(s: &str) -> bool
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.
Sourcepub fn preflight_routable_node(
&self,
network_graph: &ReadOnlyNetworkGraph<'_>,
lsp_node_pk: &NodePk,
) -> Result<NodePk, Error>
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<'de> Deserialize<'de> for Offer
impl<'de> Deserialize<'de> for Offer
Source§fn deserialize<__D>(
deserializer: __D,
) -> Result<Offer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
deserializer: __D,
) -> Result<Offer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Offer
impl Serialize for Offer
Source§fn serialize<__S>(
&self,
serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Offer
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> 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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.