Struct lightning::offers::invoice::Bolt12Invoice

source ·
pub struct Bolt12Invoice { /* private fields */ }
Expand description

A Bolt12Invoice is a payment request, typically corresponding to an Offer or a Refund.

An invoice may be sent in response to an InvoiceRequest in the case of an offer or sent directly after scanning a refund. It includes all the information needed to pay a recipient.

Implementations§

source§

impl Bolt12Invoice

source

pub fn offer_chains(&self) -> Option<Vec<ChainHash>>

The chains that may be used when paying a requested invoice.

From Offer::chains; None if the invoice was created in response to a Refund.

source

pub fn chain(&self) -> ChainHash

The chain that must be used when paying the invoice; selected from offer_chains if the invoice originated from an offer.

From InvoiceRequest::chain or Refund::chain.

source

pub fn metadata(&self) -> Option<&Vec<u8>>

Opaque bytes set by the originating Offer.

From Offer::metadata; None if the invoice was created in response to a Refund or if the Offer did not set it.

source

pub fn amount(&self) -> Option<&Amount>

The minimum amount required for a successful payment of a single item.

From Offer::amount; None if the invoice was created in response to a Refund or if the Offer did not set it.

source

pub fn offer_features(&self) -> Option<&OfferFeatures>

Features pertaining to the originating Offer.

From Offer::offer_features; None if the invoice was created in response to a Refund.

source

pub fn description(&self) -> Option<PrintableString<'_>>

A complete description of the purpose of the originating offer or refund.

From Offer::description or Refund::description.

source

pub fn absolute_expiry(&self) -> Option<Duration>

Duration since the Unix epoch when an invoice should no longer be requested.

From Offer::absolute_expiry or Refund::absolute_expiry.

source

pub fn issuer(&self) -> Option<PrintableString<'_>>

The issuer of the offer or refund.

From Offer::issuer or Refund::issuer.

source

pub fn message_paths(&self) -> &[BlindedPath]

Paths to the recipient originating from publicly reachable nodes.

From Offer::paths or Refund::paths.

source

pub fn supported_quantity(&self) -> Option<Quantity>

The quantity of items supported.

From Offer::supported_quantity; None if the invoice was created in response to a Refund.

source

pub fn payer_metadata(&self) -> &[u8]

An unpredictable series of bytes from the payer.

From InvoiceRequest::payer_metadata or Refund::payer_metadata.

source

pub fn invoice_request_features(&self) -> &InvoiceRequestFeatures

Features pertaining to requesting an invoice.

From InvoiceRequest::invoice_request_features or Refund::features.

source

pub fn quantity(&self) -> Option<u64>

The quantity of items requested or refunded for.

From InvoiceRequest::quantity or Refund::quantity.

source

pub fn payer_id(&self) -> PublicKey

A possibly transient pubkey used to sign the invoice request or to send an invoice for a refund in case there are no message_paths.

source

pub fn payer_note(&self) -> Option<PrintableString<'_>>

A payer-provided note reflected back in the invoice.

From InvoiceRequest::payer_note or Refund::payer_note.

source

pub fn payment_paths(&self) -> &[(BlindedPayInfo, BlindedPath)]

Paths to the recipient originating from publicly reachable nodes, including information needed for routing payments across them.

Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this privacy is lost if a public node id is used for Bolt12Invoice::signing_pubkey.

This is not exported to bindings users as slices with non-reference types cannot be ABI matched in another language.

source

pub fn created_at(&self) -> Duration

Duration since the Unix epoch when the invoice was created.

source

pub fn relative_expiry(&self) -> Duration

Duration since Bolt12Invoice::created_at when the invoice has expired and therefore should no longer be paid.

source

pub fn is_expired(&self) -> bool

Available on crate feature std only.

Whether the invoice has expired.

source

pub fn payment_hash(&self) -> PaymentHash

SHA256 hash of the payment preimage that will be given in return for paying the invoice.

source

pub fn amount_msats(&self) -> u64

The minimum amount required for a successful payment of the invoice.

source

pub fn fallbacks(&self) -> Vec<Address>

Fallback addresses for paying the invoice on-chain, in order of most-preferred to least-preferred.

source

pub fn invoice_features(&self) -> &Bolt12InvoiceFeatures

Features pertaining to paying an invoice.

source

pub fn signing_pubkey(&self) -> PublicKey

The public key corresponding to the key used to sign the invoice.

source

pub fn signature(&self) -> Signature

Signature of the invoice verified using Bolt12Invoice::signing_pubkey.

source

pub fn signable_hash(&self) -> [u8; 32]

Hash that was used for signing the invoice.

source

pub fn verify<T: Signing>( &self, key: &ExpandedKey, secp_ctx: &Secp256k1<T> ) -> Result<PaymentId, ()>

Verifies that the invoice was for a request or refund created using the given key. Returns the associated PaymentId to use when sending the payment.

Trait Implementations§

source§

impl Clone for Bolt12Invoice

source§

fn clone(&self) -> Bolt12Invoice

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Bolt12Invoice

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Bolt12Invoice

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Bolt12Invoice

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Vec<u8>> for Bolt12Invoice

§

type Error = Bolt12ParseError

The type returned in the event of a conversion error.
source§

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Writeable for Bolt12Invoice

source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Writes self out to the given Writer.
source§

fn encode(&self) -> Vec<u8>

Writes self out to a Vec<u8>.
source§

fn serialized_length(&self) -> usize

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length.
source§

impl Eq for Bolt12Invoice

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.