1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Details about a node in the network, known from the network announcement.
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class NodeInfo extends CommonBase {
15 NodeInfo(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
23 * All valid channels a node has announced
25 public void set_channels(long[] val) {
26 bindings.NodeInfo_set_channels(this.ptr, val);
30 * Lowest fees enabling routing via any of the enabled, known channels to a node.
31 * The two fields (flat and proportional fee) are independent,
32 * meaning they don't have to refer to the same channel.
34 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
37 public RoutingFees get_lowest_inbound_channel_fees() {
38 long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
39 if (ret < 1024) { return null; }
40 RoutingFees ret_hu_conv = new RoutingFees(null, ret);
41 ret_hu_conv.ptrs_to.add(this);
46 * Lowest fees enabling routing via any of the enabled, known channels to a node.
47 * The two fields (flat and proportional fee) are independent,
48 * meaning they don't have to refer to the same channel.
50 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
52 public void set_lowest_inbound_channel_fees(@Nullable RoutingFees val) {
53 bindings.NodeInfo_set_lowest_inbound_channel_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
54 this.ptrs_to.add(val);
58 * More information about a node from node_announcement.
59 * Optional because we store a Node entry after learning about it from
60 * a channel announcement, but before receiving a node announcement.
62 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
65 public NodeAnnouncementInfo get_announcement_info() {
66 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
67 if (ret < 1024) { return null; }
68 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
69 ret_hu_conv.ptrs_to.add(this);
74 * More information about a node from node_announcement.
75 * Optional because we store a Node entry after learning about it from
76 * a channel announcement, but before receiving a node announcement.
78 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
80 public void set_announcement_info(@Nullable NodeAnnouncementInfo val) {
81 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr & ~1);
82 this.ptrs_to.add(val);
86 * Constructs a new NodeInfo given each field
88 public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
89 long ret = bindings.NodeInfo_new(channels_arg, lowest_inbound_channel_fees_arg == null ? 0 : lowest_inbound_channel_fees_arg.ptr & ~1, announcement_info_arg == null ? 0 : announcement_info_arg.ptr & ~1);
90 if (ret < 1024) { return null; }
91 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
92 ret_hu_conv.ptrs_to.add(ret_hu_conv);
93 ret_hu_conv.ptrs_to.add(lowest_inbound_channel_fees_arg);
94 ret_hu_conv.ptrs_to.add(announcement_info_arg);
99 * Creates a copy of the NodeInfo
101 public NodeInfo clone() {
102 long ret = bindings.NodeInfo_clone(this.ptr);
103 if (ret < 1024) { return null; }
104 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
105 ret_hu_conv.ptrs_to.add(this);
110 * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
112 public byte[] write() {
113 byte[] ret = bindings.NodeInfo_write(this.ptr);
118 * Read a NodeInfo from a byte array, created by NodeInfo_write
120 public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
121 long ret = bindings.NodeInfo_read(ser);
122 if (ret < 1024) { return null; }
123 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);