Update auto-updated Java files
[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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Details about a node in the network, known from the network announcement.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class NodeInfo extends CommonBase {
16         NodeInfo(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
21         }
22
23         /**
24          * All valid channels a node has announced
25          */
26         public void set_channels(long[] val) {
27                 bindings.NodeInfo_set_channels(this.ptr, val);
28                 Reference.reachabilityFence(this);
29                 Reference.reachabilityFence(val);
30         }
31
32         /**
33          * Lowest fees enabling routing via any of the enabled, known channels to a node.
34          * The two fields (flat and proportional fee) are independent,
35          * meaning they don't have to refer to the same channel.
36          * 
37          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
38          */
39         @Nullable
40         public RoutingFees get_lowest_inbound_channel_fees() {
41                 long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
42                 Reference.reachabilityFence(this);
43                 if (ret >= 0 && ret <= 4096) { return null; }
44                 RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
45                 ret_hu_conv.ptrs_to.add(this);
46                 return ret_hu_conv;
47         }
48
49         /**
50          * Lowest fees enabling routing via any of the enabled, known channels to a node.
51          * The two fields (flat and proportional fee) are independent,
52          * meaning they don't have to refer to the same channel.
53          * 
54          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
55          */
56         public void set_lowest_inbound_channel_fees(@Nullable RoutingFees val) {
57                 bindings.NodeInfo_set_lowest_inbound_channel_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
58                 Reference.reachabilityFence(this);
59                 Reference.reachabilityFence(val);
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          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
68          */
69         @Nullable
70         public NodeAnnouncementInfo get_announcement_info() {
71                 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
72                 Reference.reachabilityFence(this);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
75                 ret_hu_conv.ptrs_to.add(this);
76                 return ret_hu_conv;
77         }
78
79         /**
80          * More information about a node from node_announcement.
81          * Optional because we store a Node entry after learning about it from
82          * a channel announcement, but before receiving a node announcement.
83          * 
84          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
85          */
86         public void set_announcement_info(@Nullable NodeAnnouncementInfo val) {
87                 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr & ~1);
88                 Reference.reachabilityFence(this);
89                 Reference.reachabilityFence(val);
90         }
91
92         /**
93          * Constructs a new NodeInfo given each field
94          */
95         public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
96                 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);
97                 Reference.reachabilityFence(channels_arg);
98                 Reference.reachabilityFence(lowest_inbound_channel_fees_arg);
99                 Reference.reachabilityFence(announcement_info_arg);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeInfo(null, ret); }
102                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
103                 return ret_hu_conv;
104         }
105
106         long clone_ptr() {
107                 long ret = bindings.NodeInfo_clone_ptr(this.ptr);
108                 Reference.reachabilityFence(this);
109                 return ret;
110         }
111
112         /**
113          * Creates a copy of the NodeInfo
114          */
115         public NodeInfo clone() {
116                 long ret = bindings.NodeInfo_clone(this.ptr);
117                 Reference.reachabilityFence(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeInfo(null, ret); }
120                 ret_hu_conv.ptrs_to.add(this);
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
126          */
127         public byte[] write() {
128                 byte[] ret = bindings.NodeInfo_write(this.ptr);
129                 Reference.reachabilityFence(this);
130                 return ret;
131         }
132
133         /**
134          * Read a NodeInfo from a byte array, created by NodeInfo_write
135          */
136         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
137                 long ret = bindings.NodeInfo_read(ser);
138                 Reference.reachabilityFence(ser);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
141                 return ret_hu_conv;
142         }
143
144 }