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 public void set_addresses(NetAddress[] val) {
111 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
112 Reference.reachabilityFence(this);
113 Reference.reachabilityFence(val);
117 * An initial announcement of the node
118 * Mostly redundant with the data we store in fields explicitly.
119 * Everything else is useful only for sending out for initial routing sync.
120 * Not stored if contains excess data to prevent DoS.
122 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
125 public NodeAnnouncement get_announcement_message() {
126 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
127 Reference.reachabilityFence(this);
128 if (ret >= 0 && ret <= 4096) { return null; }
129 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
130 ret_hu_conv.ptrs_to.add(this);
135 * An initial announcement of the node
136 * Mostly redundant with the data we store in fields explicitly.
137 * Everything else is useful only for sending out for initial routing sync.
138 * Not stored if contains excess data to prevent DoS.
140 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
142 public void set_announcement_message(@Nullable NodeAnnouncement val) {
143 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
144 Reference.reachabilityFence(this);
145 Reference.reachabilityFence(val);
149 * Constructs a new NodeAnnouncementInfo given each field
151 public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, NodeAlias alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
152 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);
153 Reference.reachabilityFence(features_arg);
154 Reference.reachabilityFence(last_update_arg);
155 Reference.reachabilityFence(rgb_arg);
156 Reference.reachabilityFence(alias_arg);
157 Reference.reachabilityFence(addresses_arg);
158 Reference.reachabilityFence(announcement_message_arg);
159 if (ret >= 0 && ret <= 4096) { return null; }
160 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
161 ret_hu_conv.ptrs_to.add(ret_hu_conv);
166 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
167 Reference.reachabilityFence(this);
172 * Creates a copy of the NodeAnnouncementInfo
174 public NodeAnnouncementInfo clone() {
175 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
176 Reference.reachabilityFence(this);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
179 ret_hu_conv.ptrs_to.add(this);
184 * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
186 public byte[] write() {
187 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
188 Reference.reachabilityFence(this);
193 * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
195 public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
196 long ret = bindings.NodeAnnouncementInfo_read(ser);
197 Reference.reachabilityFence(ser);
198 if (ret >= 0 && ret <= 4096) { return null; }
199 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);