Struct lightning_invoice::Invoice
source · [−]pub struct Invoice { /* private fields */ }
Expand description
Represents a syntactically and semantically correct lightning BOLT11 invoice.
There are three ways to construct an Invoice
:
- using
InvoiceBuilder
- using
Invoice::from_signed(SignedRawInvoice)
- using
str::parse::<Invoice>(&str)
Implementations
sourceimpl Invoice
impl Invoice
sourcepub fn into_signed_raw(self) -> SignedRawInvoice
pub fn into_signed_raw(self) -> SignedRawInvoice
Transform the Invoice
into it’s unchecked version
sourcepub fn check_signature(&self) -> Result<(), SemanticError>
pub fn check_signature(&self) -> Result<(), SemanticError>
Check that the invoice is signed correctly and that key recovery works
sourcepub fn from_signed(
signed_invoice: SignedRawInvoice
) -> Result<Self, SemanticError>
pub fn from_signed(
signed_invoice: SignedRawInvoice
) -> Result<Self, SemanticError>
Constructs an Invoice
from a SignedRawInvoice
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::<SignedRawInvoice>().unwrap();
assert!(Invoice::from_signed(signed).is_ok());
sourcepub fn timestamp(&self) -> SystemTime
Available on crate feature std
only.
pub fn timestamp(&self) -> SystemTime
std
only.Returns the Invoice
’s timestamp (should equal its creation time)
sourcepub fn duration_since_epoch(&self) -> Duration
pub fn duration_since_epoch(&self) -> Duration
Returns the Invoice
’s timestamp as a duration since the Unix epoch
sourcepub 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 Invoice.
(C-not exported) As there is not yet a manual mapping for a FilterMap
sourcepub 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
sourcepub fn description(&self) -> InvoiceDescription<'_>
pub fn description(&self) -> InvoiceDescription<'_>
Return the description or a hash of it for longer ones
(C-not exported) because we don’t yet export InvoiceDescription
sourcepub 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
sourcepub fn payment_secret(&self) -> &PaymentSecret
pub fn payment_secret(&self) -> &PaymentSecret
Get the payment secret if one was included in the invoice
sourcepub fn features(&self) -> Option<&InvoiceFeatures>
pub fn features(&self) -> Option<&InvoiceFeatures>
Get the invoice features if they were included in the invoice
sourcepub 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)
sourcepub fn expiry_time(&self) -> Duration
pub fn expiry_time(&self) -> Duration
Returns the invoice’s expiry time, if present, otherwise DEFAULT_EXPIRY_TIME
.
sourcepub fn is_expired(&self) -> bool
Available on crate feature std
only.
pub fn is_expired(&self) -> bool
std
only.Returns whether the invoice has expired.
sourcepub 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.
sourcepub fn min_final_cltv_expiry(&self) -> u64
pub fn min_final_cltv_expiry(&self) -> u64
Returns the invoice’s min_final_cltv_expiry
time, if present, otherwise
DEFAULT_MIN_FINAL_CLTV_EXPIRY
.
sourcepub fn fallbacks(&self) -> Vec<&Fallback>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn fallbacks(&self) -> Vec<&Fallback>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns a list of all fallback addresses
(C-not exported) as we don’t support Vec<&NonOpaqueType>
sourcepub fn private_routes(&self) -> Vec<&PrivateRoute>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn private_routes(&self) -> Vec<&PrivateRoute>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns a list of all routes included in the invoice
sourcepub fn route_hints(&self) -> Vec<RouteHint>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn route_hints(&self) -> Vec<RouteHint>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns a list of all routes included in the invoice as the underlying hints
sourcepub 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
sourceimpl<'de> Deserialize<'de> for Invoice
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for Invoice
serde
only.sourcefn deserialize<D>(deserializer: D) -> Result<Invoice, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Invoice, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl FromStr for Invoice
impl FromStr for Invoice
use lightning_invoice::Invoice;
let invoice = "lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\
h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\
5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\
h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\
j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\
ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\
guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\
ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\
p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\
8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\
j5r6drg6k6zcqj0fcwg";
assert!(invoice.parse::<Invoice>().is_ok());
impl Eq for Invoice
impl StructuralEq for Invoice
impl StructuralPartialEq for Invoice
Auto Trait Implementations
impl RefUnwindSafe for Invoice
impl Send for Invoice
impl Sync for Invoice
impl Unpin for Invoice
impl UnwindSafe for Invoice
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more