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 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 >= 0 && ret <= 4096) { return null; }
40                 RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { 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         }
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 >= 0 && ret <= 4096) { return null; }
67                 NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { 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         }
82
83         /**
84          * Constructs a new NodeInfo given each field
85          */
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 >= 0 && ret <= 4096) { return null; }
89                 NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeInfo(null, ret); }
90                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
91                 return ret_hu_conv;
92         }
93
94         long clone_ptr() {
95                 long ret = bindings.NodeInfo_clone_ptr(this.ptr);
96                 return ret;
97         }
98
99         /**
100          * Creates a copy of the NodeInfo
101          */
102         public NodeInfo clone() {
103                 long ret = bindings.NodeInfo_clone(this.ptr);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeInfo(null, ret); }
106                 ret_hu_conv.ptrs_to.add(this);
107                 return ret_hu_conv;
108         }
109
110         /**
111          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
112          */
113         public byte[] write() {
114                 byte[] ret = bindings.NodeInfo_write(this.ptr);
115                 return ret;
116         }
117
118         /**
119          * Read a NodeInfo from a byte array, created by NodeInfo_write
120          */
121         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
122                 long ret = bindings.NodeInfo_read(ser);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
125                 return ret_hu_conv;
126         }
127
128 }