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 * Details about a node in the network, known from the network announcement.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class NodeInfo extends CommonBase {
16 NodeInfo(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
24 * All valid channels a node has announced
26 * Returns a copy of the field.
28 public long[] get_channels() {
29 long[] ret = bindings.NodeInfo_get_channels(this.ptr);
30 Reference.reachabilityFence(this);
35 * All valid channels a node has announced
37 public void set_channels(long[] val) {
38 bindings.NodeInfo_set_channels(this.ptr, val);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * More information about a node from node_announcement.
45 * Optional because we store a Node entry after learning about it from
46 * a channel announcement, but before receiving a node announcement.
48 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
51 public NodeAnnouncementInfo get_announcement_info() {
52 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
53 Reference.reachabilityFence(this);
54 if (ret >= 0 && ret <= 4096) { return null; }
55 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
56 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
61 * More information about a node from node_announcement.
62 * Optional because we store a Node entry after learning about it from
63 * a channel announcement, but before receiving a node announcement.
65 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
67 public void set_announcement_info(@Nullable org.ldk.structs.NodeAnnouncementInfo val) {
68 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr);
69 Reference.reachabilityFence(this);
70 Reference.reachabilityFence(val);
71 if (this != null) { this.ptrs_to.add(val); };
75 * Constructs a new NodeInfo given each field
77 * Note that announcement_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
79 public static NodeInfo of(long[] channels_arg, @Nullable org.ldk.structs.NodeAnnouncementInfo announcement_info_arg) {
80 long ret = bindings.NodeInfo_new(channels_arg, announcement_info_arg == null ? 0 : announcement_info_arg.ptr);
81 Reference.reachabilityFence(channels_arg);
82 Reference.reachabilityFence(announcement_info_arg);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
86 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(announcement_info_arg); };
91 long ret = bindings.NodeInfo_clone_ptr(this.ptr);
92 Reference.reachabilityFence(this);
97 * Creates a copy of the NodeInfo
99 public NodeInfo clone() {
100 long ret = bindings.NodeInfo_clone(this.ptr);
101 Reference.reachabilityFence(this);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
109 * Checks if two NodeInfos contain equal inner contents.
110 * This ignores pointers and is_owned flags and looks at the values in fields.
111 * Two objects with NULL inner values will be considered "equal" here.
113 public boolean eq(org.ldk.structs.NodeInfo b) {
114 boolean ret = bindings.NodeInfo_eq(this.ptr, b == null ? 0 : b.ptr);
115 Reference.reachabilityFence(this);
116 Reference.reachabilityFence(b);
117 if (this != null) { this.ptrs_to.add(b); };
121 @Override public boolean equals(Object o) {
122 if (!(o instanceof NodeInfo)) return false;
123 return this.eq((NodeInfo)o);
126 * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
128 public byte[] write() {
129 byte[] ret = bindings.NodeInfo_write(this.ptr);
130 Reference.reachabilityFence(this);
135 * Read a NodeInfo from a byte array, created by NodeInfo_write
137 public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
138 long ret = bindings.NodeInfo_read(ser);
139 Reference.reachabilityFence(ser);
140 if (ret >= 0 && ret <= 4096) { return null; }
141 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);