Struct UnifiedQrPayment

Source
pub struct UnifiedQrPayment { /* private fields */ }
Expand description

A payment handler allowing to create BIP 21 URIs with an on-chain, BOLT 11, and BOLT 12 payment option.

Should be retrieved by calling Node::unified_qr_payment

Implementations§

Source§

impl UnifiedQrPayment

Source

pub fn receive( &self, amount_sats: u64, description: &str, expiry_sec: u32, ) -> Result<String, Error>

Generates a URI with an on-chain address, BOLT 11 invoice and BOLT 12 offer.

The URI allows users to send the payment request allowing the wallet to decide which payment method to use. This enables a fallback mechanism: older wallets can always pay using the provided on-chain address, while newer wallets will typically opt to use the provided BOLT11 invoice or BOLT12 offer.

The URI will always include an on-chain address. A BOLT11 invoice will be included unless invoice generation fails, while a BOLT12 offer will only be included when the node has suitable channels for routing.

§Parameters
  • amount_sats: The amount to be received, specified in satoshis.
  • description: A description or note associated with the payment. This message is visible to the payer and can provide context or details about the payment.
  • expiry_sec: The expiration time for the payment, specified in seconds.

Returns a payable URI that can be used to request and receive a payment of the amount given. Failure to generate the on-chain address will result in an error return (Error::WalletOperationFailed), while failures in invoice or offer generation will result in those components being omitted from the URI.

The generated URI can then be given to a QR code library.

Source

pub fn send(&self, uri_str: &str) -> Result<QrPaymentResult, Error>

Sends a payment given a BIP 21 URI.

This method parses the provided URI string and attempts to send the payment. If the URI has an offer and or invoice, it will try to pay the offer first followed by the invoice. If they both fail, the on-chain payment will be paid.

Returns a QrPaymentResult indicating the outcome of the payment. If an error occurs, an Error is returned detailing the issue encountered.

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

impl<T> ErasedDestructor for T
where T: 'static,