Struct Bolt11Invoice
pub struct Bolt11Invoice { /* private fields */ }
Expand description
Represents a syntactically and semantically correct lightning BOLT11 invoice.
There are three ways to construct a Bolt11Invoice
:
- using
InvoiceBuilder
- using
Bolt11Invoice::from_signed
- using
str::parse::<Bolt11Invoice>(&str)
(seeBolt11Invoice::from_str
)
Implementations§
§impl Bolt11Invoice
impl Bolt11Invoice
pub fn signable_hash(&self) -> [u8; 32]
pub fn signable_hash(&self) -> [u8; 32]
The hash of the RawBolt11Invoice
that was signed.
pub fn into_signed_raw(self) -> SignedRawBolt11Invoice
pub fn into_signed_raw(self) -> SignedRawBolt11Invoice
Transform the Bolt11Invoice
into its unchecked version.
pub fn check_signature(&self) -> Result<(), Bolt11SemanticError>
pub fn check_signature(&self) -> Result<(), Bolt11SemanticError>
Check that the invoice is signed correctly and that key recovery works
pub fn from_signed(
signed_invoice: SignedRawBolt11Invoice,
) -> Result<Bolt11Invoice, Bolt11SemanticError>
pub fn from_signed( signed_invoice: SignedRawBolt11Invoice, ) -> Result<Bolt11Invoice, Bolt11SemanticError>
Constructs a Bolt11Invoice
from a SignedRawBolt11Invoice
by checking all its invariants.
use lightning_invoice::*;
let invoice = "lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\
h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\
5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\
h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\
j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\
ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\
guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\
ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\
p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\
8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\
j5r6drg6k6zcqj0fcwg";
let signed = invoice.parse::<SignedRawBolt11Invoice>().unwrap();
assert!(Bolt11Invoice::from_signed(signed).is_ok());
pub fn timestamp(&self) -> SystemTime
pub fn timestamp(&self) -> SystemTime
Returns the Bolt11Invoice
’s timestamp (should equal its creation time)
pub fn duration_since_epoch(&self) -> Duration
pub fn duration_since_epoch(&self) -> Duration
Returns the Bolt11Invoice
’s timestamp as a duration since the Unix epoch
pub fn tagged_fields(
&self,
) -> FilterMap<Iter<'_, RawTaggedField>, fn(_: &RawTaggedField) -> Option<&TaggedField>> ⓘ
pub fn tagged_fields( &self, ) -> FilterMap<Iter<'_, RawTaggedField>, fn(_: &RawTaggedField) -> Option<&TaggedField>> ⓘ
Returns an iterator over all tagged fields of this Bolt11Invoice
.
This is not exported to bindings users as there is not yet a manual mapping for a FilterMap
pub fn payment_hash(&self) -> &Hash
pub fn payment_hash(&self) -> &Hash
Returns the hash to which we will receive the preimage on completion of the payment
pub fn description(&self) -> Bolt11InvoiceDescription<'_>
pub fn description(&self) -> Bolt11InvoiceDescription<'_>
Return the description or a hash of it for longer ones
This is not exported to bindings users because we don’t yet export Bolt11InvoiceDescription
pub fn payee_pub_key(&self) -> Option<&PublicKey>
pub fn payee_pub_key(&self) -> Option<&PublicKey>
Get the payee’s public key if one was included in the invoice
pub fn payment_secret(&self) -> &PaymentSecret
pub fn payment_secret(&self) -> &PaymentSecret
Get the payment secret if one was included in the invoice
pub fn payment_metadata(&self) -> Option<&Vec<u8>>
pub fn payment_metadata(&self) -> Option<&Vec<u8>>
Get the payment metadata blob if one was included in the invoice
pub fn features(&self) -> Option<&Features<Bolt11InvoiceContext>>
pub fn features(&self) -> Option<&Features<Bolt11InvoiceContext>>
Get the invoice features if they were included in the invoice
pub fn recover_payee_pub_key(&self) -> PublicKey
pub fn recover_payee_pub_key(&self) -> PublicKey
Recover the payee’s public key (only to be used if none was included in the invoice)
pub fn expires_at(&self) -> Option<Duration>
pub fn expires_at(&self) -> Option<Duration>
Returns the Duration since the Unix epoch at which the invoice expires. Returning None if overflow occurred.
pub fn expiry_time(&self) -> Duration
pub fn expiry_time(&self) -> Duration
Returns the invoice’s expiry time, if present, otherwise DEFAULT_EXPIRY_TIME
.
pub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns whether the invoice has expired.
pub fn duration_until_expiry(&self) -> Duration
pub fn duration_until_expiry(&self) -> Duration
Returns the Duration remaining until the invoice expires.
pub fn expiration_remaining_from_epoch(&self, time: Duration) -> Duration
pub fn expiration_remaining_from_epoch(&self, time: Duration) -> Duration
Returns the Duration remaining until the invoice expires given the current time.
time
is the timestamp as a duration since the Unix epoch.
pub fn would_expire(&self, at_time: Duration) -> bool
pub fn would_expire(&self, at_time: Duration) -> bool
Returns whether the expiry time would pass at the given point in time.
at_time
is the timestamp as a duration since the Unix epoch.
pub fn min_final_cltv_expiry_delta(&self) -> u64
pub fn min_final_cltv_expiry_delta(&self) -> u64
Returns the invoice’s min_final_cltv_expiry_delta
time, if present, otherwise
DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA
.
pub fn fallbacks(&self) -> Vec<&Fallback>
pub fn fallbacks(&self) -> Vec<&Fallback>
Returns a list of all fallback addresses
This is not exported to bindings users as we don’t support Vec<&NonOpaqueType>
pub fn fallback_addresses(&self) -> Vec<Address>
pub fn fallback_addresses(&self) -> Vec<Address>
Returns a list of all fallback addresses as Address
es
pub fn private_routes(&self) -> Vec<&PrivateRoute>
pub fn private_routes(&self) -> Vec<&PrivateRoute>
Returns a list of all routes included in the invoice
pub fn route_hints(&self) -> Vec<RouteHint>
pub fn route_hints(&self) -> Vec<RouteHint>
Returns a list of all routes included in the invoice as the underlying hints
pub fn network(&self) -> Network
pub fn network(&self) -> Network
Returns the network for which the invoice was issued
This is not exported to bindings users, see Self::currency
instead.
pub fn amount_milli_satoshis(&self) -> Option<u64>
pub fn amount_milli_satoshis(&self) -> Option<u64>
Returns the amount if specified in the invoice as millisatoshis.
Trait Implementations§
§impl Clone for Bolt11Invoice
impl Clone for Bolt11Invoice
§fn clone(&self) -> Bolt11Invoice
fn clone(&self) -> Bolt11Invoice
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for Bolt11Invoice
impl Debug for Bolt11Invoice
§impl Display for Bolt11Invoice
impl Display for Bolt11Invoice
§impl FromStr for Bolt11Invoice
impl FromStr for Bolt11Invoice
use lightning_invoice::Bolt11Invoice;
let invoice = "lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\
h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\
5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\
h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\
j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\
ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\
guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\
ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\
p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\
8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\
j5r6drg6k6zcqj0fcwg";
assert!(invoice.parse::<Bolt11Invoice>().is_ok());
§type Err = ParseOrSemanticError
type Err = ParseOrSemanticError
§fn from_str(s: &str) -> Result<Bolt11Invoice, <Bolt11Invoice as FromStr>::Err>
fn from_str(s: &str) -> Result<Bolt11Invoice, <Bolt11Invoice as FromStr>::Err>
s
to return a value of this type. Read more§impl Hash for Bolt11Invoice
impl Hash for Bolt11Invoice
§impl Ord for Bolt11Invoice
impl Ord for Bolt11Invoice
§impl PartialEq for Bolt11Invoice
impl PartialEq for Bolt11Invoice
§impl PartialOrd for Bolt11Invoice
impl PartialOrd for Bolt11Invoice
impl Eq for Bolt11Invoice
impl StructuralPartialEq for Bolt11Invoice
Auto Trait Implementations§
impl Freeze for Bolt11Invoice
impl RefUnwindSafe for Bolt11Invoice
impl Send for Bolt11Invoice
impl Sync for Bolt11Invoice
impl Unpin for Bolt11Invoice
impl UnwindSafe for Bolt11Invoice
Blanket Implementations§
§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,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<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.§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<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> 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