[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / Payee.java
index 988de3ee654be965426f9379a5dde51c567e25ed..bf515f7adf33439984cf520ee59b1bfaed61e51c 100644 (file)
@@ -9,153 +9,163 @@ import javax.annotation.Nullable;
 
 
 /**
- * The recipient of a payment.
+ * The recipient of a payment, differing based on whether they've hidden their identity with route
+ * blinding.
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class Payee extends CommonBase {
-       Payee(Object _dummy, long ptr) { super(ptr); }
+       private Payee(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
                super.finalize();
                if (ptr != 0) { bindings.Payee_free(ptr); }
        }
-
-       /**
-        * The node id of the payee.
-        */
-       public byte[] get_pubkey() {
-               byte[] ret = bindings.Payee_get_pubkey(this.ptr);
-               Reference.reachabilityFence(this);
-               return ret;
-       }
-
-       /**
-        * The node id of the payee.
-        */
-       public void set_pubkey(byte[] val) {
-               bindings.Payee_set_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
-               Reference.reachabilityFence(this);
-               Reference.reachabilityFence(val);
-       }
-
-       /**
-        * Features supported by the payee.
-        * 
-        * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
-        * does not contain any features.
-        * 
-        * [`for_keysend`]: Self::for_keysend
-        * 
-        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
-        */
-       @Nullable
-       public InvoiceFeatures get_features() {
-               long ret = bindings.Payee_get_features(this.ptr);
-               Reference.reachabilityFence(this);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Features supported by the payee.
-        * 
-        * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
-        * does not contain any features.
-        * 
-        * [`for_keysend`]: Self::for_keysend
-        * 
-        * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
-        */
-       public void set_features(@Nullable InvoiceFeatures val) {
-               bindings.Payee_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
-               Reference.reachabilityFence(this);
-               Reference.reachabilityFence(val);
+       static Payee constr_from_ptr(long ptr) {
+               bindings.LDKPayee raw_val = bindings.LDKPayee_ref_from_ptr(ptr);
+               if (raw_val.getClass() == bindings.LDKPayee.Blinded.class) {
+                       return new Blinded(ptr, (bindings.LDKPayee.Blinded)raw_val);
+               }
+               if (raw_val.getClass() == bindings.LDKPayee.Clear.class) {
+                       return new Clear(ptr, (bindings.LDKPayee.Clear)raw_val);
+               }
+               assert false; return null; // Unreachable without extending the (internal) bindings interface
+       }
+
+       /**
+        * The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves
+        * will be included in the final [`Route`].
+        */
+       public final static class Blinded extends Payee {
+               /**
+                * Aggregated routing info and blinded paths, for routing to the payee without knowing their
+                * node id.
+               */
+               public final TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints;
+               /**
+                * Features supported by the payee.
+                * 
+                * May be set from the payee's invoice. May be `None` if the invoice does not contain any
+                * features.
+                * 
+                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+               */
+               @Nullable public final org.ldk.structs.Bolt12InvoiceFeatures features;
+               private Blinded(long ptr, bindings.LDKPayee.Blinded obj) {
+                       super(null, ptr);
+                       long[] route_hints = obj.route_hints;
+                       int route_hints_conv_37_len = route_hints.length;
+                       TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints_conv_37_arr = new TwoTuple_BlindedPayInfoBlindedPathZ[route_hints_conv_37_len];
+                       for (int l = 0; l < route_hints_conv_37_len; l++) {
+                               long route_hints_conv_37 = route_hints[l];
+                               TwoTuple_BlindedPayInfoBlindedPathZ route_hints_conv_37_hu_conv = new TwoTuple_BlindedPayInfoBlindedPathZ(null, route_hints_conv_37);
+                               if (route_hints_conv_37_hu_conv != null) { route_hints_conv_37_hu_conv.ptrs_to.add(this); };
+                               route_hints_conv_37_arr[l] = route_hints_conv_37_hu_conv;
+                       }
+                       this.route_hints = route_hints_conv_37_arr;
+                       long features = obj.features;
+                       org.ldk.structs.Bolt12InvoiceFeatures features_hu_conv = null; if (features < 0 || features > 4096) { features_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, features); }
+                       if (features_hu_conv != null) { features_hu_conv.ptrs_to.add(this); };
+                       this.features = features_hu_conv;
+               }
        }
-
        /**
-        * Hints for routing to the payee, containing channels connecting the payee to public nodes.
-        */
-       public RouteHint[] get_route_hints() {
-               long[] ret = bindings.Payee_get_route_hints(this.ptr);
-               Reference.reachabilityFence(this);
-               int ret_conv_11_len = ret.length;
-               RouteHint[] ret_conv_11_arr = new RouteHint[ret_conv_11_len];
-               for (int l = 0; l < ret_conv_11_len; l++) {
-                       long ret_conv_11 = ret[l];
-                       RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new RouteHint(null, ret_conv_11); }
-                       ret_conv_11_hu_conv.ptrs_to.add(this);
-                       ret_conv_11_arr[l] = ret_conv_11_hu_conv;
+        * The recipient included these route hints in their BOLT11 invoice.
+        */
+       public final static class Clear extends Payee {
+               /**
+                * The node id of the payee.
+               */
+               public final byte[] node_id;
+               /**
+                * Hints for routing to the payee, containing channels connecting the payee to public nodes.
+               */
+               public final RouteHint[] route_hints;
+               /**
+                * Features supported by the payee.
+                * 
+                * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
+                * does not contain any features.
+                * 
+                * [`for_keysend`]: PaymentParameters::for_keysend
+                * 
+                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+               */
+               @Nullable public final org.ldk.structs.Bolt11InvoiceFeatures features;
+               /**
+                * The minimum CLTV delta at the end of the route. This value must not be zero.
+               */
+               public final int final_cltv_expiry_delta;
+               private Clear(long ptr, bindings.LDKPayee.Clear obj) {
+                       super(null, ptr);
+                       this.node_id = obj.node_id;
+                       long[] route_hints = obj.route_hints;
+                       int route_hints_conv_11_len = route_hints.length;
+                       RouteHint[] route_hints_conv_11_arr = new RouteHint[route_hints_conv_11_len];
+                       for (int l = 0; l < route_hints_conv_11_len; l++) {
+                               long route_hints_conv_11 = route_hints[l];
+                               org.ldk.structs.RouteHint route_hints_conv_11_hu_conv = null; if (route_hints_conv_11 < 0 || route_hints_conv_11 > 4096) { route_hints_conv_11_hu_conv = new org.ldk.structs.RouteHint(null, route_hints_conv_11); }
+                               if (route_hints_conv_11_hu_conv != null) { route_hints_conv_11_hu_conv.ptrs_to.add(this); };
+                               route_hints_conv_11_arr[l] = route_hints_conv_11_hu_conv;
+                       }
+                       this.route_hints = route_hints_conv_11_arr;
+                       long features = obj.features;
+                       org.ldk.structs.Bolt11InvoiceFeatures features_hu_conv = null; if (features < 0 || features > 4096) { features_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, features); }
+                       if (features_hu_conv != null) { features_hu_conv.ptrs_to.add(this); };
+                       this.features = features_hu_conv;
+                       this.final_cltv_expiry_delta = obj.final_cltv_expiry_delta;
                }
-               return ret_conv_11_arr;
        }
-
-       /**
-        * Hints for routing to the payee, containing channels connecting the payee to public nodes.
-        */
-       public void set_route_hints(RouteHint[] val) {
-               bindings.Payee_set_route_hints(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_11 -> val_conv_11 == null ? 0 : val_conv_11.ptr & ~1).toArray() : null);
+       long clone_ptr() {
+               long ret = bindings.Payee_clone_ptr(this.ptr);
                Reference.reachabilityFence(this);
-               Reference.reachabilityFence(val);
+               return ret;
        }
 
        /**
-        * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
+        * Creates a copy of the Payee
         */
-       public Option_u64Z get_expiry_time() {
-               long ret = bindings.Payee_get_expiry_time(this.ptr);
+       public Payee clone() {
+               long ret = bindings.Payee_clone(this.ptr);
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(this);
+               org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
        /**
-        * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
+        * Utility method to constructs a new Blinded-variant Payee
         */
-       public void set_expiry_time(Option_u64Z val) {
-               bindings.Payee_set_expiry_time(this.ptr, val.ptr);
-               Reference.reachabilityFence(this);
-               Reference.reachabilityFence(val);
-       }
-
-       /**
-        * Constructs a new Payee given each field
-        */
-       public static Payee of(byte[] pubkey_arg, InvoiceFeatures features_arg, RouteHint[] route_hints_arg, Option_u64Z expiry_time_arg) {
-               long ret = bindings.Payee_new(InternalUtils.check_arr_len(pubkey_arg, 33), features_arg == null ? 0 : features_arg.ptr & ~1, route_hints_arg != null ? Arrays.stream(route_hints_arg).mapToLong(route_hints_arg_conv_11 -> route_hints_arg_conv_11 == null ? 0 : route_hints_arg_conv_11.ptr & ~1).toArray() : null, expiry_time_arg.ptr);
-               Reference.reachabilityFence(pubkey_arg);
-               Reference.reachabilityFence(features_arg);
-               Reference.reachabilityFence(route_hints_arg);
-               Reference.reachabilityFence(expiry_time_arg);
+       public static Payee blinded(TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints, org.ldk.structs.Bolt12InvoiceFeatures features) {
+               long ret = bindings.Payee_blinded(route_hints != null ? Arrays.stream(route_hints).mapToLong(route_hints_conv_37 -> route_hints_conv_37.ptr).toArray() : null, features.ptr);
+               Reference.reachabilityFence(route_hints);
+               Reference.reachabilityFence(features);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features); };
                return ret_hu_conv;
        }
 
-       long clone_ptr() {
-               long ret = bindings.Payee_clone_ptr(this.ptr);
-               Reference.reachabilityFence(this);
-               return ret;
-       }
-
        /**
-        * Creates a copy of the Payee
+        * Utility method to constructs a new Clear-variant Payee
         */
-       public Payee clone() {
-               long ret = bindings.Payee_clone(this.ptr);
-               Reference.reachabilityFence(this);
+       public static Payee clear(byte[] node_id, RouteHint[] route_hints, org.ldk.structs.Bolt11InvoiceFeatures features, int final_cltv_expiry_delta) {
+               long ret = bindings.Payee_clear(InternalUtils.check_arr_len(node_id, 33), route_hints != null ? Arrays.stream(route_hints).mapToLong(route_hints_conv_11 -> route_hints_conv_11.ptr).toArray() : null, features.ptr, final_cltv_expiry_delta);
+               Reference.reachabilityFence(node_id);
+               Reference.reachabilityFence(route_hints);
+               Reference.reachabilityFence(features);
+               Reference.reachabilityFence(final_cltv_expiry_delta);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+               for (RouteHint route_hints_conv_11: route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_hints_conv_11); }; };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features); };
                return ret_hu_conv;
        }
 
        /**
-        * Checks if two Payees contain equal inner contents.
+        * Generates a non-cryptographic 64-bit hash of the Payee.
         */
        public long hash() {
                long ret = bindings.Payee_hash(this.ptr);
@@ -169,13 +179,11 @@ public class Payee extends CommonBase {
        /**
         * Checks if two Payees contain equal inner contents.
         * This ignores pointers and is_owned flags and looks at the values in fields.
-        * Two objects with NULL inner values will be considered "equal" here.
         */
-       public boolean eq(Payee b) {
-               boolean ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+       public boolean eq(org.ldk.structs.Payee b) {
+               boolean ret = bindings.Payee_eq(this.ptr, b.ptr);
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(b);
-               this.ptrs_to.add(b);
                return ret;
        }
 
@@ -183,48 +191,4 @@ public class Payee extends CommonBase {
                if (!(o instanceof Payee)) return false;
                return this.eq((Payee)o);
        }
-       /**
-        * Serialize the Payee object into a byte array which can be read by Payee_read
-        */
-       public byte[] write() {
-               byte[] ret = bindings.Payee_write(this.ptr);
-               Reference.reachabilityFence(this);
-               return ret;
-       }
-
-       /**
-        * Read a Payee from a byte array, created by Payee_write
-        */
-       public static Result_PayeeDecodeErrorZ read(byte[] ser) {
-               long ret = bindings.Payee_read(ser);
-               Reference.reachabilityFence(ser);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a payee with the node id of the given `pubkey`.
-        */
-       public static Payee from_node_id(byte[] pubkey) {
-               long ret = bindings.Payee_from_node_id(InternalUtils.check_arr_len(pubkey, 33));
-               Reference.reachabilityFence(pubkey);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a payee with the node id of the given `pubkey` to use for keysend payments.
-        */
-       public static Payee for_keysend(byte[] pubkey) {
-               long ret = bindings.Payee_for_keysend(InternalUtils.check_arr_len(pubkey, 33));
-               Reference.reachabilityFence(pubkey);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
-               return ret_hu_conv;
-       }
-
 }