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);
57 * More information about a node from node_announcement.
58 * Optional because we store a Node entry after learning about it from
59 * a channel announcement, but before receiving a node announcement.
61 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
64 public NodeAnnouncementInfo get_announcement_info() {
65 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
66 if (ret < 1024) { return null; }
67 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
68 ret_hu_conv.ptrs_to.add(this);
73 * More information about a node from node_announcement.
74 * Optional because we store a Node entry after learning about it from
75 * a channel announcement, but before receiving a node announcement.
77 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
79 public void set_announcement_info(@Nullable NodeAnnouncementInfo val) {
80 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr & ~1);
84 * Constructs a new NodeInfo given each field
86 public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
87 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);
88 if (ret < 1024) { return null; }
89 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
90 ret_hu_conv.ptrs_to.add(ret_hu_conv);
95 * Creates a copy of the NodeInfo
97 public NodeInfo clone() {
98 long ret = bindings.NodeInfo_clone(this.ptr);
99 if (ret < 1024) { return null; }
100 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
101 ret_hu_conv.ptrs_to.add(this);
106 * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
108 public byte[] write() {
109 byte[] ret = bindings.NodeInfo_write(this.ptr);
114 * Read a NodeInfo from a byte array, created by NodeInfo_write
116 public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
117 long ret = bindings.NodeInfo_read(ser);
118 if (ret < 1024) { return null; }
119 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);