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 NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
27 ret_hu_conv.ptrs_to.add(this);
32 * Protocol features the node announced support for
34 public void set_features(NodeFeatures val) {
35 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
36 this.ptrs_to.add(val);
40 * When the last known update to the node state was issued.
41 * Value is opaque, as set in the announcement.
43 public int get_last_update() {
44 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
49 * When the last known update to the node state was issued.
50 * Value is opaque, as set in the announcement.
52 public void set_last_update(int val) {
53 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
57 * Color assigned to the node
59 public byte[] get_rgb() {
60 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
65 * Color assigned to the node
67 public void set_rgb(byte[] val) {
68 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, val);
72 * Moniker assigned to the node.
73 * May be invalid or malicious (eg control chars),
74 * should not be exposed to the user.
76 public byte[] get_alias() {
77 byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
82 * Moniker assigned to the node.
83 * May be invalid or malicious (eg control chars),
84 * should not be exposed to the user.
86 public void set_alias(byte[] val) {
87 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val);
91 * Internet-level addresses via which one can connect to the node
93 public void set_addresses(NetAddress[] val) {
94 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray());
95 /* TODO 2 NetAddress */;
99 * An initial announcement of the node
100 * Mostly redundant with the data we store in fields explicitly.
101 * Everything else is useful only for sending out for initial routing sync.
102 * Not stored if contains excess data to prevent DoS.
104 public NodeAnnouncement get_announcement_message() {
105 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
106 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
107 ret_hu_conv.ptrs_to.add(this);
112 * An initial announcement of the node
113 * Mostly redundant with the data we store in fields explicitly.
114 * Everything else is useful only for sending out for initial routing sync.
115 * Not stored if contains excess data to prevent DoS.
117 public void set_announcement_message(NodeAnnouncement val) {
118 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
119 this.ptrs_to.add(val);
123 * Constructs a new NodeAnnouncementInfo given each field
125 public static NodeAnnouncementInfo constructor_new(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
126 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);
127 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
128 ret_hu_conv.ptrs_to.add(ret_hu_conv);
129 ret_hu_conv.ptrs_to.add(features_arg);
130 /* TODO 2 NetAddress */;
131 ret_hu_conv.ptrs_to.add(announcement_message_arg);
136 * Creates a copy of the NodeAnnouncementInfo
138 public NodeAnnouncementInfo clone() {
139 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
140 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
141 ret_hu_conv.ptrs_to.add(this);
146 * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
148 public byte[] write() {
149 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
154 * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
156 public static Result_NodeAnnouncementInfoDecodeErrorZ constructor_read(byte[] ser) {
157 long ret = bindings.NodeAnnouncementInfo_read(ser);
158 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);