1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * Information received in the latest node_announcement from this node.
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class NodeAnnouncementInfo extends CommonBase {
14 NodeAnnouncementInfo(Object _dummy, long ptr) { super(ptr); }
15 @Override @SuppressWarnings("deprecation")
16 protected void finalize() throws Throwable {
18 if (ptr != 0) { bindings.NodeAnnouncementInfo_free(ptr); }
22 * Protocol features the node announced support for
24 public NodeFeatures get_features() {
25 long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
26 if (ret < 1024) { return null; }
27 NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
28 ret_hu_conv.ptrs_to.add(this);
33 * Protocol features the node announced support for
35 public void set_features(NodeFeatures val) {
36 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
37 this.ptrs_to.add(val);
41 * When the last known update to the node state was issued.
42 * Value is opaque, as set in the announcement.
44 public int get_last_update() {
45 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
50 * When the last known update to the node state was issued.
51 * Value is opaque, as set in the announcement.
53 public void set_last_update(int val) {
54 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
58 * Color assigned to the node
60 public byte[] get_rgb() {
61 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
66 * Color assigned to the node
68 public void set_rgb(byte[] val) {
69 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, val);
73 * Moniker assigned to the node.
74 * May be invalid or malicious (eg control chars),
75 * should not be exposed to the user.
77 public byte[] get_alias() {
78 byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
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 void set_alias(byte[] val) {
88 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val);
92 * Internet-level addresses via which one can connect to the node
94 public void set_addresses(NetAddress[] val) {
95 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray());
96 /* TODO 2 NetAddress */;
100 * An initial announcement of the node
101 * Mostly redundant with the data we store in fields explicitly.
102 * Everything else is useful only for sending out for initial routing sync.
103 * Not stored if contains excess data to prevent DoS.
105 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
108 public NodeAnnouncement get_announcement_message() {
109 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
110 if (ret < 1024) { return null; }
111 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
112 ret_hu_conv.ptrs_to.add(this);
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 val (or a relevant inner pointer) may be NULL or all-0s to represent None
124 public void set_announcement_message(@Nullable NodeAnnouncement val) {
125 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
126 this.ptrs_to.add(val);
130 * Constructs a new NodeAnnouncementInfo given each field
132 public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
133 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, rgb_arg, alias_arg, Arrays.stream(addresses_arg).mapToLong(addresses_arg_conv_12 -> addresses_arg_conv_12.ptr).toArray(), announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
134 if (ret < 1024) { return null; }
135 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
136 ret_hu_conv.ptrs_to.add(ret_hu_conv);
137 ret_hu_conv.ptrs_to.add(features_arg);
138 /* TODO 2 NetAddress */;
139 ret_hu_conv.ptrs_to.add(announcement_message_arg);
144 * Creates a copy of the NodeAnnouncementInfo
146 public NodeAnnouncementInfo clone() {
147 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
148 if (ret < 1024) { return null; }
149 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
150 ret_hu_conv.ptrs_to.add(this);
155 * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
157 public byte[] write() {
158 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
163 * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
165 public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
166 long ret = bindings.NodeAnnouncementInfo_read(ser);
167 if (ret < 1024) { return null; }
168 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);