Enum PaymentMethod

pub enum PaymentMethod {
    Onchain {
        address: Address,
        amount: Option<Amount>,
        label: Option<String>,
        message: Option<String>,
    },
    Invoice {
        invoice: Invoice,
    },
    Offer {
        offer: Offer,
        bip321_amount: Option<Amount>,
    },
    LnurlPay {
        lnurl: String,
        pay_request: LnurlPayRequest,
    },
}
Expand description

A single “payment method” – each kind here should correspond with a single linear (outbound) payment flow for a user, where there are no other alternate methods.

For example, a Unified BTC QR code contains a single BIP321 URI, which may contain multiple discrete payment methods (an onchain address, a BOLT11 invoice, a BOLT12 offer).

Compare with ClaimMethod, which is the inbound equivalent.

Variants§

§

Onchain

Fields

§address: Address

An onchain Bitcoin address.

§amount: Option<Amount>

The amount to pay to the onchain address, if specified.

Parsed from a BIP321 URI or BOLT11 invoice containing the onchain address.

§label: Option<String>

A label for the onchain address.

Parsed from a BIP321 URI containing the onchain address.

§message: Option<String>

A message describing the transaction or its purpose.

Parsed from a BIP321 URI or BOLT11 invoice containing the onchain address.

§

Invoice

Fields

§invoice: Invoice

A BOLT11 invoice.

§

Offer

Fields

§offer: Offer

A BOLT12 offer.

§bip321_amount: Option<Amount>

The amount to pay to the offer, if specified.

Parsed from a BIP321 URI containing the offer.

§

LnurlPay

Fields

§lnurl: String

The LNURL-pay LNURL.

§pay_request: LnurlPayRequest

The LNURL-pay request, which includes information about the amount constraints, callback, etc. associated with the LNURL.

Implementations§

§

impl PaymentMethod

pub fn is_onchain(&self) -> bool

Check if the payment method is an onchain address.

pub fn is_invoice(&self) -> bool

Check if the payment method is a BOLT11 invoice.

pub fn is_offer(&self) -> bool

Check if the payment method is a BOLT12 offer.

pub fn is_lnurl_pay(&self) -> bool

Check if the payment method is an LNURL-pay endpoint.

pub fn kind(&self) -> &'static str

Get the “kind” of the payment method as a string: “onchain”, “invoice”, “offer”, or “lnurl-pay”.

pub fn supports_network(&self, network: Network) -> bool

Check if the payment method is valid for the given Network.

pub fn priority(&self) -> usize

For use with sort_by_key, max_by_key, etc. Payment methods with a higher priority should be preferred over others.

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
§

impl<F, T, U> Apply<F, U> for T
where F: FnOnce(T) -> U,

§

fn apply(self, f: F) -> U

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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<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