Update auto-generated Java bindings (all functionally equivalent)
[ldk-java] / src / main / java / org / ldk / structs / Payee.java
index 922f4883e802fe281b058eb50f1f622b7c0022a1..988de3ee654be965426f9379a5dde51c567e25ed 100644 (file)
@@ -4,6 +4,7 @@ import org.ldk.impl.bindings;
 import org.ldk.enums.*;
 import org.ldk.util.*;
 import java.util.Arrays;
+import java.lang.ref.Reference;
 import javax.annotation.Nullable;
 
 
@@ -24,6 +25,7 @@ public class Payee extends CommonBase {
         */
        public byte[] get_pubkey() {
                byte[] ret = bindings.Payee_get_pubkey(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
@@ -31,7 +33,9 @@ public class Payee extends CommonBase {
         * The node id of the payee.
         */
        public void set_pubkey(byte[] val) {
-               bindings.Payee_set_pubkey(this.ptr, val);
+               bindings.Payee_set_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
        }
 
        /**
@@ -47,6 +51,7 @@ public class Payee extends CommonBase {
        @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);
@@ -65,6 +70,8 @@ public class Payee extends CommonBase {
         */
        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);
        }
 
        /**
@@ -72,8 +79,10 @@ public class Payee extends CommonBase {
         */
        public RouteHint[] get_route_hints() {
                long[] ret = bindings.Payee_get_route_hints(this.ptr);
-               RouteHint[] ret_conv_11_arr = new RouteHint[ret.length];
-               for (int l = 0; l < ret.length; l++) {
+               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);
@@ -87,6 +96,8 @@ public class Payee extends CommonBase {
         */
        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);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
        }
 
        /**
@@ -94,6 +105,7 @@ public class Payee extends CommonBase {
         */
        public Option_u64Z get_expiry_time() {
                long ret = bindings.Payee_get_expiry_time(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);
@@ -105,24 +117,37 @@ public class Payee extends CommonBase {
         */
        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(pubkey_arg, 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);
+               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);
                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;
        }
 
+       long clone_ptr() {
+               long ret = bindings.Payee_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
        /**
         * Creates a copy of the Payee
         */
        public Payee clone() {
                long ret = bindings.Payee_clone(this.ptr);
+               Reference.reachabilityFence(this);
                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);
@@ -134,9 +159,13 @@ public class Payee extends CommonBase {
         */
        public long hash() {
                long ret = bindings.Payee_hash(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
        /**
         * Checks if two Payees contain equal inner contents.
         * This ignores pointers and is_owned flags and looks at the values in fields.
@@ -144,15 +173,22 @@ public class Payee extends CommonBase {
         */
        public boolean eq(Payee b) {
                boolean ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(b);
                this.ptrs_to.add(b);
                return ret;
        }
 
+       @Override public boolean equals(Object o) {
+               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;
        }
 
@@ -161,6 +197,7 @@ public class Payee extends CommonBase {
         */
        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;
@@ -170,7 +207,8 @@ public class Payee extends CommonBase {
         * 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(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);
@@ -181,7 +219,8 @@ public class Payee extends CommonBase {
         * 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(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);