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 ret_hu_conv.ptrs_to.add(this);
36 * Protocol features the node announced support for
38 public void set_features(NodeFeatures val) {
39 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
45 * When the last known update to the node state was issued.
46 * Value is opaque, as set in the announcement.
48 public int get_last_update() {
49 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
50 Reference.reachabilityFence(this);
55 * When the last known update to the node state was issued.
56 * Value is opaque, as set in the announcement.
58 public void set_last_update(int val) {
59 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
60 Reference.reachabilityFence(this);
61 Reference.reachabilityFence(val);
65 * Color assigned to the node
67 public byte[] get_rgb() {
68 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
69 Reference.reachabilityFence(this);
74 * Color assigned to the node
76 public void set_rgb(byte[] val) {
77 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
78 Reference.reachabilityFence(this);
79 Reference.reachabilityFence(val);
83 * Moniker assigned to the node.
84 * May be invalid or malicious (eg control chars),
85 * should not be exposed to the user.
87 public NodeAlias get_alias() {
88 long ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
92 ret_hu_conv.ptrs_to.add(this);
97 * Moniker assigned to the node.
98 * May be invalid or malicious (eg control chars),
99 * should not be exposed to the user.
101 public void set_alias(NodeAlias val) {
102 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val == null ? 0 : val.ptr & ~1);
103 Reference.reachabilityFence(this);
104 Reference.reachabilityFence(val);
108 * Internet-level addresses via which one can connect to the node
110 * Returns a copy of the field.
112 public NetAddress[] get_addresses() {
113 long[] ret = bindings.NodeAnnouncementInfo_get_addresses(this.ptr);
114 Reference.reachabilityFence(this);
115 int ret_conv_12_len = ret.length;
116 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
117 for (int m = 0; m < ret_conv_12_len; m++) {
118 long ret_conv_12 = ret[m];
119 org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
120 ret_conv_12_hu_conv.ptrs_to.add(this);
121 ret_conv_12_arr[m] = ret_conv_12_hu_conv;
123 return ret_conv_12_arr;
127 * Internet-level addresses via which one can connect to the node
129 public void set_addresses(NetAddress[] val) {
130 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
131 Reference.reachabilityFence(this);
132 Reference.reachabilityFence(val);
136 * An initial announcement of the node
137 * Mostly redundant with the data we store in fields explicitly.
138 * Everything else is useful only for sending out for initial routing sync.
139 * Not stored if contains excess data to prevent DoS.
141 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
144 public NodeAnnouncement get_announcement_message() {
145 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
146 Reference.reachabilityFence(this);
147 if (ret >= 0 && ret <= 4096) { return null; }
148 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
149 ret_hu_conv.ptrs_to.add(this);
154 * An initial announcement of the node
155 * Mostly redundant with the data we store in fields explicitly.
156 * Everything else is useful only for sending out for initial routing sync.
157 * Not stored if contains excess data to prevent DoS.
159 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
161 public void set_announcement_message(@Nullable NodeAnnouncement val) {
162 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
163 Reference.reachabilityFence(this);
164 Reference.reachabilityFence(val);
168 * Constructs a new NodeAnnouncementInfo given each field
170 public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, NodeAlias alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
171 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, InternalUtils.check_arr_len(rgb_arg, 3), alias_arg == null ? 0 : alias_arg.ptr & ~1, addresses_arg != null ? Arrays.stream(addresses_arg).mapToLong(addresses_arg_conv_12 -> addresses_arg_conv_12.ptr).toArray() : null, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
172 Reference.reachabilityFence(features_arg);
173 Reference.reachabilityFence(last_update_arg);
174 Reference.reachabilityFence(rgb_arg);
175 Reference.reachabilityFence(alias_arg);
176 Reference.reachabilityFence(addresses_arg);
177 Reference.reachabilityFence(announcement_message_arg);
178 if (ret >= 0 && ret <= 4096) { return null; }
179 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
180 ret_hu_conv.ptrs_to.add(ret_hu_conv);
185 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
186 Reference.reachabilityFence(this);
191 * Creates a copy of the NodeAnnouncementInfo
193 public NodeAnnouncementInfo clone() {
194 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
195 Reference.reachabilityFence(this);
196 if (ret >= 0 && ret <= 4096) { return null; }
197 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
198 ret_hu_conv.ptrs_to.add(this);
203 * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
205 public byte[] write() {
206 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
207 Reference.reachabilityFence(this);
212 * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
214 public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
215 long ret = bindings.NodeAnnouncementInfo_read(ser);
216 Reference.reachabilityFence(ser);
217 if (ret >= 0 && ret <= 4096) { return null; }
218 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);