[][src]Struct lightning_invoice::Invoice

pub struct Invoice { /* fields omitted */ }

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)

Methods

impl Invoice
[src]

pub fn into_signed_raw(self) -> SignedRawInvoice
[src]

Transform the Invoice into it's unchecked version

pub fn check_signature(&self) -> Result<(), SemanticError>
[src]

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

pub fn from_signed(
    signed_invoice: SignedRawInvoice
) -> Result<Self, SemanticError>
[src]

Constructs an Invoice from a SignedInvoice by checking all its invariants.

use lightning_invoice::*;

let invoice = "lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\
    l2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\
    3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\
    ky03ylcqca784w";

let signed = invoice.parse::<SignedRawInvoice>().unwrap();

assert!(Invoice::from_signed(signed).is_ok());

pub fn timestamp(&self) -> &SystemTime
[src]

Returns the Invoice's timestamp (should equal it's creation time)

pub fn tagged_fields(
    &self
) -> FilterMap<Iter<RawTaggedField>, fn(_: &RawTaggedField) -> Option<&TaggedField>>
[src]

Returns an iterator over all tagged fields of this Invoice.

pub fn payment_hash(&self) -> &Sha256
[src]

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

pub fn description(&self) -> InvoiceDescription
[src]

Return the description or a hash of it for longer ones

pub fn payee_pub_key(&self) -> Option<&PayeePubKey>
[src]

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

pub fn recover_payee_pub_key(&self) -> PayeePubKey
[src]

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

pub fn expiry_time(&self) -> Option<&ExpiryTime>
[src]

Returns the invoice's expiry time if present

pub fn min_final_cltv_expiry(&self) -> Option<&MinFinalCltvExpiry>
[src]

Returns the invoice's min_cltv_expiry time if present

pub fn fallbacks(&self) -> Vec<&Fallback>
[src]

Returns a list of all fallback addresses

pub fn routes(&self) -> Vec<&Route>
[src]

Returns a list of all routes included in the invoice

pub fn currency(&self) -> Currency
[src]

Returns the currency for which the invoice was issued

pub fn amount_pico_btc(&self) -> Option<u64>
[src]

Returns the amount if specified in the invoice as pico .

Trait Implementations

impl Clone for Invoice
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Invoice
[src]

impl PartialEq<Invoice> for Invoice
[src]

impl Display for Invoice
[src]

impl Debug for Invoice
[src]

impl FromStr for Invoice
[src]

use lightning_invoice::Invoice;

let invoice = "lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\
    l2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\
    3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\
    ky03ylcqca784w";

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

type Err = ParseOrSemanticError

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for Invoice

impl Sync for Invoice

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

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

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]