Struct lightning_invoice::payment::InvoicePayerUsingTime
source · pub struct InvoicePayerUsingTime<P: Deref, R: Router, L: Deref, E: BaseEventHandler, T: Time>where
P::Target: Payer,
L::Target: Logger,{ /* private fields */ }
Expand description
(C-not exported) generally all users should use the InvoicePayer
type alias.
Implementations§
source§impl<P: Deref, R: Router, L: Deref, E: BaseEventHandler, T: Time> InvoicePayerUsingTime<P, R, L, E, T>where
P::Target: Payer,
L::Target: Logger,
impl<P: Deref, R: Router, L: Deref, E: BaseEventHandler, T: Time> InvoicePayerUsingTime<P, R, L, E, T>where
P::Target: Payer,
L::Target: Logger,
sourcepub fn new(payer: P, router: R, logger: L, event_handler: E, retry: Retry) -> Self
pub fn new(payer: P, router: R, logger: L, event_handler: E, retry: Retry) -> Self
Creates an invoice payer that retries failed payment paths.
Will forward any Event::PaymentPathFailed
events to the decorated event_handler
once
retry
has been exceeded for a given Invoice
.
sourcepub fn pay_invoice(&self, invoice: &Invoice) -> Result<PaymentId, PaymentError>
pub fn pay_invoice(&self, invoice: &Invoice) -> Result<PaymentId, PaymentError>
Pays the given Invoice
, caching it for later use in case a retry is needed.
Invoice::payment_hash
is used as the PaymentId
, which ensures idempotency as long
as the payment is still pending. Once the payment completes or fails, you must ensure that
a second payment with the same PaymentHash
is never sent.
If you wish to use a different payment idempotency token, see
Self::pay_invoice_with_id
.
sourcepub fn pay_invoice_with_id(
&self,
invoice: &Invoice,
payment_id: PaymentId
) -> Result<(), PaymentError>
pub fn pay_invoice_with_id(
&self,
invoice: &Invoice,
payment_id: PaymentId
) -> Result<(), PaymentError>
Pays the given Invoice
with a custom idempotency key, caching the invoice for later use
in case a retry is needed.
Note that idempotency is only guaranteed as long as the payment is still pending. Once the payment completes or fails, no idempotency guarantees are made.
You should ensure that the Invoice::payment_hash
is unique and the same PaymentHash
has never been paid before.
See Self::pay_invoice
for a variant which uses the PaymentHash
for the idempotency
token.
sourcepub fn pay_zero_value_invoice(
&self,
invoice: &Invoice,
amount_msats: u64
) -> Result<PaymentId, PaymentError>
pub fn pay_zero_value_invoice(
&self,
invoice: &Invoice,
amount_msats: u64
) -> Result<PaymentId, PaymentError>
Pays the given zero-value Invoice
using the given amount, caching it for later use in
case a retry is needed.
Invoice::payment_hash
is used as the PaymentId
, which ensures idempotency as long
as the payment is still pending. Once the payment completes or fails, you must ensure that
a second payment with the same PaymentHash
is never sent.
If you wish to use a different payment idempotency token, see
Self::pay_zero_value_invoice_with_id
.
sourcepub fn pay_zero_value_invoice_with_id(
&self,
invoice: &Invoice,
amount_msats: u64,
payment_id: PaymentId
) -> Result<(), PaymentError>
pub fn pay_zero_value_invoice_with_id(
&self,
invoice: &Invoice,
amount_msats: u64,
payment_id: PaymentId
) -> Result<(), PaymentError>
Pays the given zero-value Invoice
using the given amount and custom idempotency key,
caching the invoice for later use in case a retry is needed.
Note that idempotency is only guaranteed as long as the payment is still pending. Once the payment completes or fails, no idempotency guarantees are made.
You should ensure that the Invoice::payment_hash
is unique and the same PaymentHash
has never been paid before.
See Self::pay_zero_value_invoice
for a variant which uses the PaymentHash
for the
idempotency token.
sourcepub fn pay_pubkey(
&self,
pubkey: PublicKey,
payment_preimage: PaymentPreimage,
amount_msats: u64,
final_cltv_expiry_delta: u32
) -> Result<PaymentId, PaymentError>
pub fn pay_pubkey(
&self,
pubkey: PublicKey,
payment_preimage: PaymentPreimage,
amount_msats: u64,
final_cltv_expiry_delta: u32
) -> Result<PaymentId, PaymentError>
Pays pubkey
an amount using the hash of the given preimage, caching it for later use in
case a retry is needed.
The hash of the PaymentPreimage
is used as the PaymentId
, which ensures idempotency
as long as the payment is still pending. Once the payment completes or fails, you must
ensure that a second payment with the same PaymentPreimage
is never sent.
sourcepub fn pay_pubkey_with_id(
&self,
pubkey: PublicKey,
payment_preimage: PaymentPreimage,
payment_id: PaymentId,
amount_msats: u64,
final_cltv_expiry_delta: u32
) -> Result<(), PaymentError>
pub fn pay_pubkey_with_id(
&self,
pubkey: PublicKey,
payment_preimage: PaymentPreimage,
payment_id: PaymentId,
amount_msats: u64,
final_cltv_expiry_delta: u32
) -> Result<(), PaymentError>
Pays pubkey
an amount using the hash of the given preimage and a custom idempotency key,
caching the invoice for later use in case a retry is needed.
Note that idempotency is only guaranteed as long as the payment is still pending. Once the payment completes or fails, no idempotency guarantees are made.
You should ensure that the PaymentPreimage
is unique and the corresponding
PaymentHash
has never been paid before.
sourcepub fn remove_cached_payment(&self, payment_hash: &PaymentHash)
pub fn remove_cached_payment(&self, payment_hash: &PaymentHash)
Removes the payment cached by the given payment hash.
Should be called once a payment has failed or succeeded if not using InvoicePayer
as an
EventHandler
. Otherwise, calling this method is unnecessary.
source§impl<P: Deref, R: Router, L: Deref, T: Time, F: Future, H: Fn(Event) -> F> InvoicePayerUsingTime<P, R, L, H, T>where
P::Target: Payer,
L::Target: Logger,
impl<P: Deref, R: Router, L: Deref, T: Time, F: Future, H: Fn(Event) -> F> InvoicePayerUsingTime<P, R, L, H, T>where
P::Target: Payer,
L::Target: Logger,
sourcepub async fn handle_event_async(&self, event: Event)
pub async fn handle_event_async(&self, event: Event)
Intercepts events required by the InvoicePayer
and forwards them to the underlying event
handler, if necessary, to handle them asynchronously.