[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / NodeId.java
index e74d649ae688fa69a0c5b9770ee08929feaae4e4..b18198869c36351686441741a4cb67c473ab29c7 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;
 
 
@@ -19,14 +20,21 @@ public class NodeId extends CommonBase {
                if (ptr != 0) { bindings.NodeId_free(ptr); }
        }
 
+       long clone_ptr() {
+               long ret = bindings.NodeId_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
        /**
         * Creates a copy of the NodeId
         */
        public NodeId clone() {
                long ret = bindings.NodeId_clone(this.ptr);
+               Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -34,10 +42,11 @@ public class NodeId extends CommonBase {
         * Create a new NodeId from a public key
         */
        public static NodeId from_pubkey(byte[] pubkey) {
-               long ret = bindings.NodeId_from_pubkey(pubkey);
+               long ret = bindings.NodeId_from_pubkey(InternalUtils.check_arr_len(pubkey, 33));
+               Reference.reachabilityFence(pubkey);
                if (ret >= 0 && ret <= 4096) { return null; }
-               NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -46,22 +55,39 @@ public class NodeId extends CommonBase {
         */
        public byte[] as_slice() {
                byte[] ret = bindings.NodeId_as_slice(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
        /**
-        * Checks if two NodeIds contain equal inner contents.
+        * Get the public key from this NodeId
+        */
+       public Result_PublicKeySecp256k1ErrorZ as_pubkey() {
+               long ret = bindings.NodeId_as_pubkey(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Generates a non-cryptographic 64-bit hash of the NodeId.
         */
        public long hash() {
                long ret = bindings.NodeId_hash(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
        /**
         * Serialize the NodeId object into a byte array which can be read by NodeId_read
         */
        public byte[] write() {
                byte[] ret = bindings.NodeId_write(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
@@ -70,6 +96,7 @@ public class NodeId extends CommonBase {
         */
        public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NodeId_read(ser);
+               Reference.reachabilityFence(ser);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;