+ /**
+ * Pays the given [`Invoice`], retrying if needed based on [`Retry`].
+ *
+ * [`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 [`pay_invoice_with_id`].
+ */
+ public static Result_PaymentIdPaymentErrorZ pay_invoice(org.ldk.structs.Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ Reference.reachabilityFence(invoice);
+ Reference.reachabilityFence(retry_strategy);
+ Reference.reachabilityFence(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given [`Invoice`] with a custom idempotency key, retrying if needed based on [`Retry`].
+ *
+ * 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 [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
+ */
+ public static Result_NonePaymentErrorZ pay_invoice_with_id(org.ldk.structs.Invoice invoice, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_invoice_with_id(invoice == null ? 0 : invoice.ptr, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ Reference.reachabilityFence(invoice);
+ Reference.reachabilityFence(payment_id);
+ Reference.reachabilityFence(retry_strategy);
+ Reference.reachabilityFence(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given zero-value [`Invoice`] using the given amount, retrying if needed based on
+ * [`Retry`].
+ *
+ * [`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
+ * [`pay_zero_value_invoice_with_id`].
+ */
+ public static Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(org.ldk.structs.Invoice invoice, long amount_msats, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ Reference.reachabilityFence(invoice);
+ Reference.reachabilityFence(amount_msats);
+ Reference.reachabilityFence(retry_strategy);
+ Reference.reachabilityFence(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given zero-value [`Invoice`] using the given amount and custom idempotency key,
+ * , retrying if needed based on [`Retry`].
+ *
+ * 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 [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
+ * idempotency token.
+ */
+ public static Result_NonePaymentErrorZ pay_zero_value_invoice_with_id(org.ldk.structs.Invoice invoice, long amount_msats, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_zero_value_invoice_with_id(invoice == null ? 0 : invoice.ptr, amount_msats, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ Reference.reachabilityFence(invoice);
+ Reference.reachabilityFence(amount_msats);
+ Reference.reachabilityFence(payment_id);
+ Reference.reachabilityFence(retry_strategy);
+ Reference.reachabilityFence(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
+ return ret_hu_conv;
+ }
+