[Java] Update auto-generated Java bindings for 0.0.113
[ldk-java] / src / main / java / org / ldk / structs / Payer.java
index 8cefcd05599d3a8a8aeace480ef7a9474b95547e..206d184d518877242198056be9fa98ff0ecc5f47 100644 (file)
@@ -9,6 +9,18 @@ import javax.annotation.Nullable;
 
 /**
  * A trait defining behavior of an [`Invoice`] payer.
+ * 
+ * While the behavior of [`InvoicePayer`] provides idempotency of duplicate `send_*payment` calls
+ * with the same [`PaymentHash`], it is up to the `Payer` to provide idempotency across restarts.
+ * 
+ * [`ChannelManager`] provides idempotency for duplicate payments with the same [`PaymentId`].
+ * 
+ * In order to trivially ensure idempotency for payments, the default `Payer` implementation
+ * reuses the [`PaymentHash`] bytes as the [`PaymentId`]. Custom implementations wishing to
+ * provide payment idempotency with a different idempotency key (i.e. [`PaymentId`]) should map
+ * the [`Invoice`] or spontaneous payment target pubkey to their own idempotency key.
+ * 
+ * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class Payer extends CommonBase {
@@ -38,11 +50,11 @@ public class Payer extends CommonBase {
                 * 
                 * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
                 */
-               Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, byte[] payment_secret);
+               Result_NonePaymentSendFailureZ send_payment(Route route, byte[] payment_hash, byte[] payment_secret, byte[] payment_id);
                /**
                 * Sends a spontaneous payment over the Lightning Network using the given [`Route`].
                 */
-               Result_PaymentIdPaymentSendFailureZ send_spontaneous_payment(Route route, byte[] payment_preimage);
+               Result_NonePaymentSendFailureZ send_spontaneous_payment(Route route, byte[] payment_preimage, byte[] payment_id);
                /**
                 * Retries a failed payment path for the [`PaymentId`] using the given [`Route`].
                 */
@@ -51,6 +63,11 @@ public class Payer extends CommonBase {
                 * Signals that no further retries for the given payment will occur.
                 */
                void abandon_payment(byte[] payment_id);
+               /**
+                * Construct an [`InFlightHtlcs`] containing information about currently used up liquidity
+                * across payments.
+                */
+               InFlightHtlcs inflight_htlcs();
        }
        private static class LDKPayerHolder { Payer held; }
        public static Payer new_impl(PayerInterface arg) {
@@ -68,16 +85,16 @@ public class Payer extends CommonBase {
                                long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_16 -> ret_conv_16 == null ? 0 : ret_conv_16.clone_ptr()).toArray() : null;
                                return result;
                        }
-                       @Override public long send_payment(long route, byte[] payment_hash, byte[] payment_secret) {
+                       @Override public long send_payment(long route, byte[] payment_hash, byte[] payment_secret, byte[] payment_id) {
                                org.ldk.structs.Route route_hu_conv = null; if (route < 0 || route > 4096) { route_hu_conv = new org.ldk.structs.Route(null, route); }
-                               Result_PaymentIdPaymentSendFailureZ ret = arg.send_payment(route_hu_conv, payment_hash, payment_secret);
+                               Result_NonePaymentSendFailureZ ret = arg.send_payment(route_hu_conv, payment_hash, payment_secret, payment_id);
                                Reference.reachabilityFence(arg);
                                long result = ret == null ? 0 : ret.clone_ptr();
                                return result;
                        }
-                       @Override public long send_spontaneous_payment(long route, byte[] payment_preimage) {
+                       @Override public long send_spontaneous_payment(long route, byte[] payment_preimage, byte[] payment_id) {
                                org.ldk.structs.Route route_hu_conv = null; if (route < 0 || route > 4096) { route_hu_conv = new org.ldk.structs.Route(null, route); }
-                               Result_PaymentIdPaymentSendFailureZ ret = arg.send_spontaneous_payment(route_hu_conv, payment_preimage);
+                               Result_NonePaymentSendFailureZ ret = arg.send_spontaneous_payment(route_hu_conv, payment_preimage, payment_id);
                                Reference.reachabilityFence(arg);
                                long result = ret == null ? 0 : ret.clone_ptr();
                                return result;
@@ -93,6 +110,12 @@ public class Payer extends CommonBase {
                                arg.abandon_payment(payment_id);
                                Reference.reachabilityFence(arg);
                        }
+                       @Override public long inflight_htlcs() {
+                               InFlightHtlcs ret = arg.inflight_htlcs();
+                               Reference.reachabilityFence(arg);
+                               long result = ret == null ? 0 : ret.clone_ptr();
+                               return result;
+                       }
                });
                return impl_holder.held;
        }
@@ -127,14 +150,15 @@ public class Payer extends CommonBase {
         * 
         * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, @Nullable byte[] payment_secret) {
-               long ret = bindings.Payer_send_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
+       public Result_NonePaymentSendFailureZ send_payment(org.ldk.structs.Route route, byte[] payment_hash, @Nullable byte[] payment_secret, byte[] payment_id) {
+               long ret = bindings.Payer_send_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), InternalUtils.check_arr_len(payment_id, 32));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(route);
                Reference.reachabilityFence(payment_hash);
                Reference.reachabilityFence(payment_secret);
+               Reference.reachabilityFence(payment_id);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
+               Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                if (this != null) { this.ptrs_to.add(route); };
                return ret_hu_conv;
        }
@@ -142,13 +166,14 @@ public class Payer extends CommonBase {
        /**
         * Sends a spontaneous payment over the Lightning Network using the given [`Route`].
         */
-       public Result_PaymentIdPaymentSendFailureZ send_spontaneous_payment(Route route, byte[] payment_preimage) {
-               long ret = bindings.Payer_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
+       public Result_NonePaymentSendFailureZ send_spontaneous_payment(org.ldk.structs.Route route, byte[] payment_preimage, byte[] payment_id) {
+               long ret = bindings.Payer_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_id, 32));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(route);
                Reference.reachabilityFence(payment_preimage);
+               Reference.reachabilityFence(payment_id);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
+               Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                if (this != null) { this.ptrs_to.add(route); };
                return ret_hu_conv;
        }
@@ -156,7 +181,7 @@ public class Payer extends CommonBase {
        /**
         * Retries a failed payment path for the [`PaymentId`] using the given [`Route`].
         */
-       public Result_NonePaymentSendFailureZ retry_payment(Route route, byte[] payment_id) {
+       public Result_NonePaymentSendFailureZ retry_payment(org.ldk.structs.Route route, byte[] payment_id) {
                long ret = bindings.Payer_retry_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_id, 32));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(route);
@@ -176,4 +201,17 @@ public class Payer extends CommonBase {
                Reference.reachabilityFence(payment_id);
        }
 
+       /**
+        * Construct an [`InFlightHtlcs`] containing information about currently used up liquidity
+        * across payments.
+        */
+       public InFlightHtlcs inflight_htlcs() {
+               long ret = bindings.Payer_inflight_htlcs(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
 }