pub struct Invoice { /* private fields */ }
Expand description

Represents a syntactically and semantically correct lightning BOLT11 invoice.

There are three ways to construct an Invoice:

  1. using InvoiceBuilder
  2. using Invoice::from_signed(SignedRawInvoice)
  3. using str::parse::<Invoice>(&str)

Implementations

Transform the Invoice into it’s unchecked version

Check that the invoice is signed correctly and that key recovery works

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());
This is supported on crate feature std only.

Returns the Invoice’s timestamp (should equal its creation time)

Returns the Invoice’s timestamp as a duration since the Unix epoch

Returns an iterator over all tagged fields of this Invoice.

(C-not exported) As there is not yet a manual mapping for a FilterMap

Returns the hash to which we will receive the preimage on completion of the payment

Return the description or a hash of it for longer ones

(C-not exported) because we don’t yet export InvoiceDescription

Get the payee’s public key if one was included in the invoice

Get the payment secret if one was included in the invoice

Get the invoice features if they were included in the invoice

Recover the payee’s public key (only to be used if none was included in the invoice)

Returns the invoice’s expiry time, if present, otherwise DEFAULT_EXPIRY_TIME.

This is supported on crate feature std only.

Returns whether the invoice has expired.

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.

Returns the invoice’s min_final_cltv_expiry time, if present, otherwise DEFAULT_MIN_FINAL_CLTV_EXPIRY.

Returns a list of all fallback addresses

(C-not exported) as we don’t support Vec<&NonOpaqueType>

Returns a list of all routes included in the invoice

Returns a list of all routes included in the invoice as the underlying hints

Returns the currency for which the invoice was issued

Returns the amount if specified in the invoice as millisatoshis.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

use lightning_invoice::Invoice;


let invoice = "lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\
h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\
5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\
h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\
j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\
ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\
guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\
ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\
p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\
8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\
j5r6drg6k6zcqj0fcwg";

assert!(invoice.parse::<Invoice>().is_ok());

The associated error which can be returned from parsing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.