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
impl UnifiedQrPayment
Sourcepub fn receive(
&self,
amount_sats: u64,
description: &str,
expiry_sec: u32,
) -> Result<String, Error>
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.
Sourcepub fn send(&self, uri_str: &str) -> Result<QrPaymentResult, Error>
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§
impl Freeze for UnifiedQrPayment
impl !RefUnwindSafe for UnifiedQrPayment
impl Send for UnifiedQrPayment
impl Sync for UnifiedQrPayment
impl Unpin for UnifiedQrPayment
impl !UnwindSafe for UnifiedQrPayment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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