Update auto-generated bindings to latest upstream
[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 import javax.annotation.Nullable;
8
9
10 /**
11  * Details about a node in the network, known from the network announcement.
12  */
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 {
18                 super.finalize();
19                 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
20         }
21
22         /**
23          * All valid channels a node has announced
24          */
25         public void set_channels(long[] val) {
26                 bindings.NodeInfo_set_channels(this.ptr, val);
27         }
28
29         /**
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.
33          * 
34          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
35          */
36         @Nullable
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);
42                 return ret_hu_conv;
43         }
44
45         /**
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.
49          * 
50          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
51          */
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);
55         }
56
57         /**
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.
61          * 
62          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
63          */
64         @Nullable
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);
70                 return ret_hu_conv;
71         }
72
73         /**
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.
77          * 
78          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
79          */
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);
83         }
84
85         /**
86          * Constructs a new NodeInfo given each field
87          */
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);
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Creates a copy of the NodeInfo
100          */
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);
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
111          */
112         public byte[] write() {
113                 byte[] ret = bindings.NodeInfo_write(this.ptr);
114                 return ret;
115         }
116
117         /**
118          * Read a NodeInfo from a byte array, created by NodeInfo_write
119          */
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);
124                 return ret_hu_conv;
125         }
126
127 }