Package org.ldk.structs
Class InvoicePayer
- java.lang.Object
-
- org.ldk.structs.InvoicePayer
-
public class InvoicePayer extends Object
A utility for paying [`Invoice`]s and sending spontaneous payments. See [module-level documentation] for details. [module-level documentation]: crate::payment
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EventHandleras_EventHandler()Constructs a new EventHandler which calls the relevant methods on this_arg.protected voidfinalize()static InvoicePayerof(Payer payer, Router router, Logger logger, EventHandler event_handler, Retry retry)Creates an invoice payer that retries failed payment paths.Result_PaymentIdPaymentErrorZpay_invoice(Invoice invoice)Pays the given [`Invoice`], caching it for later use in case a retry is needed.Result_NonePaymentErrorZpay_invoice_with_id(Invoice invoice, byte[] payment_id)Pays the given [`Invoice`] with a custom idempotency key, caching the invoice for later use in case a retry is needed.Result_PaymentIdPaymentErrorZpay_pubkey(byte[] pubkey, byte[] payment_preimage, long amount_msats, int final_cltv_expiry_delta)Pays `pubkey` an amount using the hash of the given preimage, caching it for later use in case a retry is needed.Result_NonePaymentErrorZpay_pubkey_with_id(byte[] pubkey, byte[] payment_preimage, byte[] payment_id, long amount_msats, int final_cltv_expiry_delta)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.Result_PaymentIdPaymentErrorZpay_zero_value_invoice(Invoice invoice, long amount_msats)Pays the given zero-value [`Invoice`] using the given amount, caching it for later use in case a retry is needed.Result_NonePaymentErrorZpay_zero_value_invoice_with_id(Invoice invoice, long amount_msats, byte[] payment_id)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.voidremove_cached_payment(byte[] payment_hash)Removes the payment cached by the given payment hash.
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
of
public static InvoicePayer of(Payer payer, Router router, Logger logger, EventHandler event_handler, Retry retry)
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`].
-
pay_invoice
public Result_PaymentIdPaymentErrorZ pay_invoice(Invoice invoice)
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`].
-
pay_invoice_with_id
public Result_NonePaymentErrorZ pay_invoice_with_id(Invoice invoice, byte[] payment_id)
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.
-
pay_zero_value_invoice
public Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(Invoice invoice, long amount_msats)
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`].
-
pay_zero_value_invoice_with_id
public Result_NonePaymentErrorZ pay_zero_value_invoice_with_id(Invoice invoice, long amount_msats, byte[] payment_id)
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.
-
pay_pubkey
public Result_PaymentIdPaymentErrorZ pay_pubkey(byte[] pubkey, byte[] payment_preimage, long amount_msats, int final_cltv_expiry_delta)
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.
-
pay_pubkey_with_id
public Result_NonePaymentErrorZ pay_pubkey_with_id(byte[] pubkey, byte[] payment_preimage, byte[] payment_id, long amount_msats, int final_cltv_expiry_delta)
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.
-
remove_cached_payment
public void remove_cached_payment(byte[] payment_hash)
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.
-
as_EventHandler
public EventHandler as_EventHandler()
Constructs a new EventHandler which calls the relevant methods on this_arg. This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
-
-