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 * Information received in the latest node_announcement from this node.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class NodeAnnouncementInfo extends CommonBase {
16 NodeAnnouncementInfo(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.NodeAnnouncementInfo_free(ptr); }
24 * Protocol features the node announced support for
26 public NodeFeatures get_features() {
27 long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
28 Reference.reachabilityFence(this);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36 * Protocol features the node announced support for
38 public void set_features(org.ldk.structs.NodeFeatures val) {
39 bindings.NodeAnnouncementInfo_set_features(this.ptr, val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
42 if (this != null) { this.ptrs_to.add(val); };
46 * When the last known update to the node state was issued.
47 * Value is opaque, as set in the announcement.
49 public int get_last_update() {
50 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
51 Reference.reachabilityFence(this);
56 * When the last known update to the node state was issued.
57 * Value is opaque, as set in the announcement.
59 public void set_last_update(int val) {
60 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * Color assigned to the node
68 public byte[] get_rgb() {
69 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
70 Reference.reachabilityFence(this);
75 * Color assigned to the node
77 public void set_rgb(byte[] val) {
78 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * Moniker assigned to the node.
85 * May be invalid or malicious (eg control chars),
86 * should not be exposed to the user.
88 public NodeAlias get_alias() {
89 long ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
90 Reference.reachabilityFence(this);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
98 * Moniker assigned to the node.
99 * May be invalid or malicious (eg control chars),
100 * should not be exposed to the user.
102 public void set_alias(org.ldk.structs.NodeAlias val) {
103 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val.ptr);
104 Reference.reachabilityFence(this);
105 Reference.reachabilityFence(val);
106 if (this != null) { this.ptrs_to.add(val); };
110 * An initial announcement of the node
111 * Mostly redundant with the data we store in fields explicitly.
112 * Everything else is useful only for sending out for initial routing sync.
113 * Not stored if contains excess data to prevent DoS.
115 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
118 public NodeAnnouncement get_announcement_message() {
119 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
120 Reference.reachabilityFence(this);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
128 * An initial announcement of the node
129 * Mostly redundant with the data we store in fields explicitly.
130 * Everything else is useful only for sending out for initial routing sync.
131 * Not stored if contains excess data to prevent DoS.
133 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
135 public void set_announcement_message(@Nullable org.ldk.structs.NodeAnnouncement val) {
136 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
137 Reference.reachabilityFence(this);
138 Reference.reachabilityFence(val);
139 if (this != null) { this.ptrs_to.add(val); };
143 * Constructs a new NodeAnnouncementInfo given each field
145 * Note that announcement_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
147 public static NodeAnnouncementInfo of(org.ldk.structs.NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, org.ldk.structs.NodeAlias alias_arg, @Nullable org.ldk.structs.NodeAnnouncement announcement_message_arg) {
148 long ret = bindings.NodeAnnouncementInfo_new(features_arg.ptr, last_update_arg, InternalUtils.check_arr_len(rgb_arg, 3), alias_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr);
149 Reference.reachabilityFence(features_arg);
150 Reference.reachabilityFence(last_update_arg);
151 Reference.reachabilityFence(rgb_arg);
152 Reference.reachabilityFence(alias_arg);
153 Reference.reachabilityFence(announcement_message_arg);
154 if (ret >= 0 && ret <= 4096) { return null; }
155 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
156 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features_arg); };
158 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(alias_arg); };
159 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(announcement_message_arg); };
164 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
165 Reference.reachabilityFence(this);
170 * Creates a copy of the NodeAnnouncementInfo
172 public NodeAnnouncementInfo clone() {
173 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
174 Reference.reachabilityFence(this);
175 if (ret >= 0 && ret <= 4096) { return null; }
176 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
177 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
182 * Checks if two NodeAnnouncementInfos contain equal inner contents.
183 * This ignores pointers and is_owned flags and looks at the values in fields.
184 * Two objects with NULL inner values will be considered "equal" here.
186 public boolean eq(org.ldk.structs.NodeAnnouncementInfo b) {
187 boolean ret = bindings.NodeAnnouncementInfo_eq(this.ptr, b.ptr);
188 Reference.reachabilityFence(this);
189 Reference.reachabilityFence(b);
190 if (this != null) { this.ptrs_to.add(b); };
194 @Override public boolean equals(Object o) {
195 if (!(o instanceof NodeAnnouncementInfo)) return false;
196 return this.eq((NodeAnnouncementInfo)o);
199 * Internet-level addresses via which one can connect to the node
201 public SocketAddress[] addresses() {
202 long[] ret = bindings.NodeAnnouncementInfo_addresses(this.ptr);
203 Reference.reachabilityFence(this);
204 int ret_conv_15_len = ret.length;
205 SocketAddress[] ret_conv_15_arr = new SocketAddress[ret_conv_15_len];
206 for (int p = 0; p < ret_conv_15_len; p++) {
207 long ret_conv_15 = ret[p];
208 org.ldk.structs.SocketAddress ret_conv_15_hu_conv = org.ldk.structs.SocketAddress.constr_from_ptr(ret_conv_15);
209 if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.add(this); };
210 ret_conv_15_arr[p] = ret_conv_15_hu_conv;
212 return ret_conv_15_arr;
216 * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
218 public byte[] write() {
219 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
220 Reference.reachabilityFence(this);
225 * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
227 public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
228 long ret = bindings.NodeAnnouncementInfo_read(ser);
229 Reference.reachabilityFence(ser);
230 if (ret >= 0 && ret <= 4096) { return null; }
231 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);