[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / UnsignedNodeAnnouncement.java
index 3a20d82091d4118f0690b0b9e23b85fcd3df4e1c..022534511c38fe29aaf51d4da2cb738bb03beb19 100644 (file)
@@ -2,74 +2,216 @@ package org.ldk.structs;
 
 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;
 
+
+/**
+ * The unsigned part of a [`node_announcement`] message.
+ * 
+ * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class UnsignedNodeAnnouncement extends CommonBase {
        UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
-               bindings.UnsignedNodeAnnouncement_free(ptr); super.finalize();
+               super.finalize();
+               if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
        }
 
-       public UnsignedNodeAnnouncement(UnsignedNodeAnnouncement orig) {
-               super(bindings.UnsignedNodeAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1));
-               this.ptrs_to.add(orig);
+       /**
+        * The advertised features
+        */
+       public NodeFeatures get_features() {
+               long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
        }
 
-       public NodeFeatures get_features(UnsignedNodeAnnouncement this_ptr) {
-               NodeFeatures ret = new NodeFeatures(null, bindings.UnsignedNodeAnnouncement_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1));
-               this.ptrs_to.add(this_ptr);
-               return ret;
+       /**
+        * The advertised features
+        */
+       public void set_features(org.ldk.structs.NodeFeatures val) {
+               bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+               if (this != null) { this.ptrs_to.add(val); };
        }
 
-       // Skipped UnsignedNodeAnnouncement_set_features
-       public int get_timestamp(UnsignedNodeAnnouncement this_ptr) {
-               int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * A strictly monotonic announcement counter, with gaps allowed
+        */
+       public int get_timestamp() {
+               int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
-       public void set_timestamp(UnsignedNodeAnnouncement this_ptr, int val) {
-               bindings.UnsignedNodeAnnouncement_set_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * A strictly monotonic announcement counter, with gaps allowed
+        */
+       public void set_timestamp(int val) {
+               bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+       }
+
+       /**
+        * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
+        * to this node).
+        */
+       public NodeId get_node_id() {
+               long ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               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;
        }
 
-       public byte[] get_node_id(UnsignedNodeAnnouncement this_ptr) {
-               byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
+        * to this node).
+        */
+       public void set_node_id(org.ldk.structs.NodeId val) {
+               bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val == null ? 0 : val.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+               if (this != null) { this.ptrs_to.add(val); };
+       }
+
+       /**
+        * An RGB color for UI purposes
+        */
+       public byte[] get_rgb() {
+               byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
-       public void set_node_id(UnsignedNodeAnnouncement this_ptr, byte[] val) {
-               bindings.UnsignedNodeAnnouncement_set_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * An RGB color for UI purposes
+        */
+       public void set_rgb(byte[] val) {
+               bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+       }
+
+       /**
+        * An alias, for UI purposes.
+        * 
+        * This should be sanitized before use. There is no guarantee of uniqueness.
+        */
+       public NodeAlias get_alias() {
+               long ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
        }
 
-       public byte[] get_rgb(UnsignedNodeAnnouncement this_ptr) {
-               byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * An alias, for UI purposes.
+        * 
+        * This should be sanitized before use. There is no guarantee of uniqueness.
+        */
+       public void set_alias(org.ldk.structs.NodeAlias val) {
+               bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, val == null ? 0 : val.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+               if (this != null) { this.ptrs_to.add(val); };
+       }
+
+       /**
+        * List of addresses on which this node is reachable
+        * 
+        * Returns a copy of the field.
+        */
+       public SocketAddress[] get_addresses() {
+               long[] ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
+               Reference.reachabilityFence(this);
+               int ret_conv_15_len = ret.length;
+               SocketAddress[] ret_conv_15_arr = new SocketAddress[ret_conv_15_len];
+               for (int p = 0; p < ret_conv_15_len; p++) {
+                       long ret_conv_15 = ret[p];
+                       org.ldk.structs.SocketAddress ret_conv_15_hu_conv = org.ldk.structs.SocketAddress.constr_from_ptr(ret_conv_15);
+                       if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.add(this); };
+                       ret_conv_15_arr[p] = ret_conv_15_hu_conv;
+               }
+               return ret_conv_15_arr;
+       }
+
+       /**
+        * List of addresses on which this node is reachable
+        */
+       public void set_addresses(SocketAddress[] val) {
+               bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15.ptr).toArray() : null);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+               for (SocketAddress val_conv_15: val) { if (this != null) { this.ptrs_to.add(val_conv_15); }; };
+       }
+
+       long clone_ptr() {
+               long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
-       public void set_rgb(UnsignedNodeAnnouncement this_ptr, byte[] val) {
-               bindings.UnsignedNodeAnnouncement_set_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * Creates a copy of the UnsignedNodeAnnouncement
+        */
+       public UnsignedNodeAnnouncement clone() {
+               long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
        }
 
-       public byte[] get_alias(UnsignedNodeAnnouncement this_ptr) {
-               byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * Checks if two UnsignedNodeAnnouncements 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(org.ldk.structs.UnsignedNodeAnnouncement b) {
+               boolean ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(b);
+               if (this != null) { this.ptrs_to.add(b); };
                return ret;
        }
 
-       public void set_alias(UnsignedNodeAnnouncement this_ptr, byte[] val) {
-               bindings.UnsignedNodeAnnouncement_set_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       @Override public boolean equals(Object o) {
+               if (!(o instanceof UnsignedNodeAnnouncement)) return false;
+               return this.eq((UnsignedNodeAnnouncement)o);
+       }
+       /**
+        * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
        }
 
-       // Skipped UnsignedNodeAnnouncement_set_addresses
-       // Skipped UnsignedNodeAnnouncement_write
-       public UnsignedNodeAnnouncement(byte[] ser) {
-               super(bindings.UnsignedNodeAnnouncement_read(ser));
+       /**
+        * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
+        */
+       public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.UnsignedNodeAnnouncement_read(ser);
+               Reference.reachabilityFence(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
        }
 
 }