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         public RoutingFees get_lowest_inbound_channel_fees() {
34                 long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
35                 RoutingFees ret_hu_conv = new RoutingFees(null, ret);
36                 ret_hu_conv.ptrs_to.add(this);
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Lowest fees enabling routing via any of the enabled, known channels to a node.
42          * The two fields (flat and proportional fee) are independent,
43          * meaning they don't have to refer to the same channel.
44          */
45         public void set_lowest_inbound_channel_fees(RoutingFees val) {
46                 bindings.NodeInfo_set_lowest_inbound_channel_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
47                 this.ptrs_to.add(val);
48         }
49
50         /**
51          * More information about a node from node_announcement.
52          * Optional because we store a Node entry after learning about it from
53          * a channel announcement, but before receiving a node announcement.
54          */
55         public NodeAnnouncementInfo get_announcement_info() {
56                 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
57                 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
58                 ret_hu_conv.ptrs_to.add(this);
59                 return ret_hu_conv;
60         }
61
62         /**
63          * More information about a node from node_announcement.
64          * Optional because we store a Node entry after learning about it from
65          * a channel announcement, but before receiving a node announcement.
66          */
67         public void set_announcement_info(NodeAnnouncementInfo val) {
68                 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr & ~1);
69                 this.ptrs_to.add(val);
70         }
71
72         /**
73          * Constructs a new NodeInfo given each field
74          */
75         public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
76                 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);
77                 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
78                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
79                 ret_hu_conv.ptrs_to.add(lowest_inbound_channel_fees_arg);
80                 ret_hu_conv.ptrs_to.add(announcement_info_arg);
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Creates a copy of the NodeInfo
86          */
87         public NodeInfo clone() {
88                 long ret = bindings.NodeInfo_clone(this.ptr);
89                 NodeInfo ret_hu_conv = new NodeInfo(null, ret);
90                 ret_hu_conv.ptrs_to.add(this);
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
96          */
97         public byte[] write() {
98                 byte[] ret = bindings.NodeInfo_write(this.ptr);
99                 return ret;
100         }
101
102         /**
103          * Read a NodeInfo from a byte array, created by NodeInfo_write
104          */
105         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
106                 long ret = bindings.NodeInfo_read(ser);
107                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
108                 return ret_hu_conv;
109         }
110
111 }