1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * The unsigned part of a [`node_announcement`] message.
14 * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UnsignedNodeAnnouncement extends CommonBase {
18 UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
26 * The advertised features
28 public NodeFeatures get_features() {
29 long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38 * The advertised features
40 public void set_features(org.ldk.structs.NodeFeatures val) {
41 bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * A strictly monotonic announcement counter, with gaps allowed
50 public int get_timestamp() {
51 int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
52 Reference.reachabilityFence(this);
57 * A strictly monotonic announcement counter, with gaps allowed
59 public void set_timestamp(int val) {
60 bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
69 public NodeId get_node_id() {
70 long ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
71 Reference.reachabilityFence(this);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
79 * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
82 public void set_node_id(org.ldk.structs.NodeId val) {
83 bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val == null ? 0 : val.ptr);
84 Reference.reachabilityFence(this);
85 Reference.reachabilityFence(val);
86 if (this != null) { this.ptrs_to.add(val); };
90 * An RGB color for UI purposes
92 public byte[] get_rgb() {
93 byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
94 Reference.reachabilityFence(this);
99 * An RGB color for UI purposes
101 public void set_rgb(byte[] val) {
102 bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
103 Reference.reachabilityFence(this);
104 Reference.reachabilityFence(val);
108 * An alias, for UI purposes.
110 * This should be sanitized before use. There is no guarantee of uniqueness.
112 public byte[] get_alias() {
113 byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
114 Reference.reachabilityFence(this);
119 * An alias, for UI purposes.
121 * This should be sanitized before use. There is no guarantee of uniqueness.
123 public void set_alias(byte[] val) {
124 bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, InternalUtils.check_arr_len(val, 32));
125 Reference.reachabilityFence(this);
126 Reference.reachabilityFence(val);
130 * List of addresses on which this node is reachable
132 * Returns a copy of the field.
134 public NetAddress[] get_addresses() {
135 long[] ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
136 Reference.reachabilityFence(this);
137 int ret_conv_12_len = ret.length;
138 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
139 for (int m = 0; m < ret_conv_12_len; m++) {
140 long ret_conv_12 = ret[m];
141 org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
142 if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.add(this); };
143 ret_conv_12_arr[m] = ret_conv_12_hu_conv;
145 return ret_conv_12_arr;
149 * List of addresses on which this node is reachable
151 public void set_addresses(NetAddress[] val) {
152 bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
153 Reference.reachabilityFence(this);
154 Reference.reachabilityFence(val);
155 for (NetAddress val_conv_12: val) { if (this != null) { this.ptrs_to.add(val_conv_12); }; };
159 long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
160 Reference.reachabilityFence(this);
165 * Creates a copy of the UnsignedNodeAnnouncement
167 public UnsignedNodeAnnouncement clone() {
168 long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
169 Reference.reachabilityFence(this);
170 if (ret >= 0 && ret <= 4096) { return null; }
171 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
172 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
177 * Checks if two UnsignedNodeAnnouncements contain equal inner contents.
178 * This ignores pointers and is_owned flags and looks at the values in fields.
179 * Two objects with NULL inner values will be considered "equal" here.
181 public boolean eq(org.ldk.structs.UnsignedNodeAnnouncement b) {
182 boolean ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
183 Reference.reachabilityFence(this);
184 Reference.reachabilityFence(b);
185 if (this != null) { this.ptrs_to.add(b); };
189 @Override public boolean equals(Object o) {
190 if (!(o instanceof UnsignedNodeAnnouncement)) return false;
191 return this.eq((UnsignedNodeAnnouncement)o);
194 * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
196 public byte[] write() {
197 byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
198 Reference.reachabilityFence(this);
203 * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
205 public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
206 long ret = bindings.UnsignedNodeAnnouncement_read(ser);
207 Reference.reachabilityFence(ser);
208 if (ret >= 0 && ret <= 4096) { return null; }
209 Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);