Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / NodeInfo.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8
9 /**
10  * Details about a node in the network, known from the network announcement.
11  */
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class NodeInfo extends CommonBase {
14         NodeInfo(Object _dummy, long ptr) { super(ptr); }
15         @Override @SuppressWarnings("deprecation")
16         protected void finalize() throws Throwable {
17                 super.finalize();
18                 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
19         }
20
21         /**
22          * All valid channels a node has announced
23          */
24         public void set_channels(long[] val) {
25                 bindings.NodeInfo_set_channels(this.ptr, val);
26         }
27
28         /**
29          * Lowest fees enabling routing via any of the enabled, known channels to a node.
30          * The two fields (flat and proportional fee) are independent,
31          * meaning they don't have to refer to the same channel.
32          * 
33          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
34          */
35         @Nullable
36         public RoutingFees get_lowest_inbound_channel_fees() {
37                 long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
38                 if (ret < 1024) { return null; }
39                 RoutingFees ret_hu_conv = new RoutingFees(null, ret);
40                 ret_hu_conv.ptrs_to.add(this);
41                 return ret_hu_conv;
42         }
43
44         /**
45          * Lowest fees enabling routing via any of the enabled, known channels to a node.
46          * The two fields (flat and proportional fee) are independent,
47          * meaning they don't have to refer to the same channel.
48          * 
49          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
50          */
51         public void set_lowest_inbound_channel_fees(@Nullable RoutingFees val) {
52                 bindings.NodeInfo_set_lowest_inbound_channel_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
53                 this.ptrs_to.add(val);
54         }
55
56         /**
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.
60          * 
61          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
62          */
63         @Nullable
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);
69                 return ret_hu_conv;
70         }
71
72         /**
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.
76          * 
77          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
78          */
79         public void set_announcement_info(@Nullable NodeAnnouncementInfo val) {
80                 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr & ~1);
81                 this.ptrs_to.add(val);
82         }
83
84         /**
85          * Constructs a new NodeInfo given each field
86          */
87         public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
88                 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);
89                 if (ret < 1024) { return null; }
90                 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
91                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
92                 ret_hu_conv.ptrs_to.add(lowest_inbound_channel_fees_arg);
93                 ret_hu_conv.ptrs_to.add(announcement_info_arg);
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Creates a copy of the NodeInfo
99          */
100         public NodeInfo clone() {
101                 long ret = bindings.NodeInfo_clone(this.ptr);
102                 if (ret < 1024) { return null; }
103                 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
104                 ret_hu_conv.ptrs_to.add(this);
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
110          */
111         public byte[] write() {
112                 byte[] ret = bindings.NodeInfo_write(this.ptr);
113                 return ret;
114         }
115
116         /**
117          * Read a NodeInfo from a byte array, created by NodeInfo_write
118          */
119         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
120                 long ret = bindings.NodeInfo_read(ser);
121                 if (ret < 1024) { return null; }
122                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
123                 return ret_hu_conv;
124         }
125
126 }