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 * The unsigned part of a node_announcement
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class UnsignedNodeAnnouncement extends CommonBase {
16 UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
24 * The advertised features
26 public NodeFeatures get_features() {
27 long ret = bindings.UnsignedNodeAnnouncement_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 * The advertised features
38 public void set_features(NodeFeatures val) {
39 bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
42 if (this != null) { this.ptrs_to.add(val); };
46 * A strictly monotonic announcement counter, with gaps allowed
48 public int get_timestamp() {
49 int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
50 Reference.reachabilityFence(this);
55 * A strictly monotonic announcement counter, with gaps allowed
57 public void set_timestamp(int val) {
58 bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
64 * The node_id this announcement originated from (don't rebroadcast the node_announcement back
67 public byte[] get_node_id() {
68 byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
69 Reference.reachabilityFence(this);
74 * The node_id this announcement originated from (don't rebroadcast the node_announcement back
77 public void set_node_id(byte[] val) {
78 bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * An RGB color for UI purposes
86 public byte[] get_rgb() {
87 byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
88 Reference.reachabilityFence(this);
93 * An RGB color for UI purposes
95 public void set_rgb(byte[] val) {
96 bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
97 Reference.reachabilityFence(this);
98 Reference.reachabilityFence(val);
102 * An alias, for UI purposes. This should be sanitized before use. There is no guarantee
105 public byte[] get_alias() {
106 byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
107 Reference.reachabilityFence(this);
112 * An alias, for UI purposes. This should be sanitized before use. There is no guarantee
115 public void set_alias(byte[] val) {
116 bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, InternalUtils.check_arr_len(val, 32));
117 Reference.reachabilityFence(this);
118 Reference.reachabilityFence(val);
122 * List of addresses on which this node is reachable
124 * Returns a copy of the field.
126 public NetAddress[] get_addresses() {
127 long[] ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
128 Reference.reachabilityFence(this);
129 int ret_conv_12_len = ret.length;
130 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
131 for (int m = 0; m < ret_conv_12_len; m++) {
132 long ret_conv_12 = ret[m];
133 org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
134 if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.add(this); };
135 ret_conv_12_arr[m] = ret_conv_12_hu_conv;
137 return ret_conv_12_arr;
141 * List of addresses on which this node is reachable
143 public void set_addresses(NetAddress[] val) {
144 bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
145 Reference.reachabilityFence(this);
146 Reference.reachabilityFence(val);
150 long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
151 Reference.reachabilityFence(this);
156 * Creates a copy of the UnsignedNodeAnnouncement
158 public UnsignedNodeAnnouncement clone() {
159 long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
160 Reference.reachabilityFence(this);
161 if (ret >= 0 && ret <= 4096) { return null; }
162 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
163 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
168 * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
170 public byte[] write() {
171 byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
172 Reference.reachabilityFence(this);
177 * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
179 public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
180 long ret = bindings.UnsignedNodeAnnouncement_read(ser);
181 Reference.reachabilityFence(ser);
182 if (ret >= 0 && ret <= 4096) { return null; }
183 Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);