Bolt12Invoice

Struct 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 payment_paths(&self) -> &[BlindedPaymentPath]

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.

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

Whether the invoice has expired.

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) -> &Features<Bolt12InvoiceContext>

Features pertaining to paying an invoice.

Source

pub fn signing_pubkey(&self) -> PublicKey

A typically transient public key corresponding to the key used to sign the invoice.

If the invoices was created in response to an Offer, then this will be:

If the invoice was created in response to a Refund, then it is a valid pubkey chosen by the recipient.

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<&Features<OfferContext>>

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) -> &[BlindedMessagePath]

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 issuer_signing_pubkey(&self) -> Option<PublicKey>

The public key used by the recipient to sign invoices.

From Offer::issuer_signing_pubkey and may be None; also 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) -> &Features<InvoiceRequestContext>

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_signing_pubkey(&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_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 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_using_metadata<T>( &self, key: &ExpandedKey, secp_ctx: &Secp256k1<T>, ) -> Result<PaymentId, ()>
where T: Signing,

Verifies that the invoice was for a request or refund created using the given key by checking the payer metadata from the invoice request.

Returns the associated PaymentId to use when sending the payment.

Source

pub fn verify_using_payer_data<T>( &self, payment_id: PaymentId, nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1<T>, ) -> Result<PaymentId, ()>
where T: Signing,

Verifies that the invoice was for a request or refund created using the given key by checking a payment id and nonce included with the BlindedMessagePath for which the invoice was sent through.

Trait Implementations§

Source§

impl Clone for Bolt12Invoice

Source§

fn clone(&self) -> Bolt12Invoice

Returns a duplicate 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<(), Error>

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

impl Hash for Bolt12Invoice

Source§

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

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: &Bolt12Invoice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Readable for Bolt12Invoice

Source§

fn read<R>(reader: &mut R) -> Result<Bolt12Invoice, DecodeError>
where R: Read,

Reads a Self in from the given Read.
Source§

impl TryFrom<ParsedMessage<(PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, InvoiceTlvStream, SignatureTlvStream, ExperimentalOfferTlvStream, ExperimentalInvoiceRequestTlvStream, ExperimentalInvoiceTlvStream)>> for Bolt12Invoice

Source§

type Error = Bolt12ParseError

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

fn try_from( invoice: ParsedMessage<(PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, InvoiceTlvStream, SignatureTlvStream, ExperimentalOfferTlvStream, ExperimentalInvoiceRequestTlvStream, ExperimentalInvoiceTlvStream)>, ) -> Result<Bolt12Invoice, <Bolt12Invoice as TryFrom<ParsedMessage<(PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, InvoiceTlvStream, SignatureTlvStream, ExperimentalOfferTlvStream, ExperimentalInvoiceRequestTlvStream, ExperimentalInvoiceTlvStream)>>>::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for Bolt12Invoice

Source§

type Error = Bolt12ParseError

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

fn try_from( bytes: Vec<u8>, ) -> Result<Bolt12Invoice, <Bolt12Invoice as TryFrom<Vec<u8>>>::Error>

Performs the conversion.
Source§

impl Writeable for Bolt12Invoice

Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeReadable for T
where T: Readable,

Source§

fn read<R>(reader: &mut R) -> Result<Option<T>, DecodeError>
where R: Read,

Reads a Self in from the given Read.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more