Update CI references to 0.0.122
[ldk-java] / src / main / java / org / ldk / structs / ChannelInfo.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 channel (both directions).
13  * Received within a channel announcement.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class ChannelInfo extends CommonBase {
17         ChannelInfo(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.ChannelInfo_free(ptr); }
22         }
23
24         /**
25          * Protocol features of a channel communicated during its announcement
26          */
27         public ChannelFeatures get_features() {
28                 long ret = bindings.ChannelInfo_get_features(this.ptr);
29                 Reference.reachabilityFence(this);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
32                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Protocol features of a channel communicated during its announcement
38          */
39         public void set_features(org.ldk.structs.ChannelFeatures val) {
40                 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43                 if (this != null) { this.ptrs_to.add(val); };
44         }
45
46         /**
47          * Source node of the first direction of a channel
48          */
49         public NodeId get_node_one() {
50                 long ret = bindings.ChannelInfo_get_node_one(this.ptr);
51                 Reference.reachabilityFence(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
54                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Source node of the first direction of a channel
60          */
61         public void set_node_one(org.ldk.structs.NodeId val) {
62                 bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65                 if (this != null) { this.ptrs_to.add(val); };
66         }
67
68         /**
69          * Details about the first direction of a channel
70          * 
71          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
72          */
73         @Nullable
74         public ChannelUpdateInfo get_one_to_two() {
75                 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
76                 Reference.reachabilityFence(this);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Details about the first direction of a channel
85          * 
86          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
87          */
88         public void set_one_to_two(@Nullable org.ldk.structs.ChannelUpdateInfo val) {
89                 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr);
90                 Reference.reachabilityFence(this);
91                 Reference.reachabilityFence(val);
92                 if (this != null) { this.ptrs_to.add(val); };
93         }
94
95         /**
96          * Source node of the second direction of a channel
97          */
98         public NodeId get_node_two() {
99                 long ret = bindings.ChannelInfo_get_node_two(this.ptr);
100                 Reference.reachabilityFence(this);
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
104                 return ret_hu_conv;
105         }
106
107         /**
108          * Source node of the second direction of a channel
109          */
110         public void set_node_two(org.ldk.structs.NodeId val) {
111                 bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr);
112                 Reference.reachabilityFence(this);
113                 Reference.reachabilityFence(val);
114                 if (this != null) { this.ptrs_to.add(val); };
115         }
116
117         /**
118          * Details about the second direction of a channel
119          * 
120          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
121          */
122         @Nullable
123         public ChannelUpdateInfo get_two_to_one() {
124                 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
125                 Reference.reachabilityFence(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Details about the second direction of a channel
134          * 
135          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
136          */
137         public void set_two_to_one(@Nullable org.ldk.structs.ChannelUpdateInfo val) {
138                 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr);
139                 Reference.reachabilityFence(this);
140                 Reference.reachabilityFence(val);
141                 if (this != null) { this.ptrs_to.add(val); };
142         }
143
144         /**
145          * The channel capacity as seen on-chain, if chain lookup is available.
146          */
147         public Option_u64Z get_capacity_sats() {
148                 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
149                 Reference.reachabilityFence(this);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
152                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
153                 return ret_hu_conv;
154         }
155
156         /**
157          * The channel capacity as seen on-chain, if chain lookup is available.
158          */
159         public void set_capacity_sats(org.ldk.structs.Option_u64Z val) {
160                 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
161                 Reference.reachabilityFence(this);
162                 Reference.reachabilityFence(val);
163                 if (this != null) { this.ptrs_to.add(val); };
164         }
165
166         /**
167          * An initial announcement of the channel
168          * Mostly redundant with the data we store in fields explicitly.
169          * Everything else is useful only for sending out for initial routing sync.
170          * Not stored if contains excess data to prevent DoS.
171          * 
172          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
173          */
174         @Nullable
175         public ChannelAnnouncement get_announcement_message() {
176                 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
177                 Reference.reachabilityFence(this);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
181                 return ret_hu_conv;
182         }
183
184         /**
185          * An initial announcement of the channel
186          * Mostly redundant with the data we store in fields explicitly.
187          * Everything else is useful only for sending out for initial routing sync.
188          * Not stored if contains excess data to prevent DoS.
189          * 
190          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
191          */
192         public void set_announcement_message(@Nullable org.ldk.structs.ChannelAnnouncement val) {
193                 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
194                 Reference.reachabilityFence(this);
195                 Reference.reachabilityFence(val);
196                 if (this != null) { this.ptrs_to.add(val); };
197         }
198
199         long clone_ptr() {
200                 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
201                 Reference.reachabilityFence(this);
202                 return ret;
203         }
204
205         /**
206          * Creates a copy of the ChannelInfo
207          */
208         public ChannelInfo clone() {
209                 long ret = bindings.ChannelInfo_clone(this.ptr);
210                 Reference.reachabilityFence(this);
211                 if (ret >= 0 && ret <= 4096) { return null; }
212                 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
213                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
214                 return ret_hu_conv;
215         }
216
217         /**
218          * Checks if two ChannelInfos contain equal inner contents.
219          * This ignores pointers and is_owned flags and looks at the values in fields.
220          * Two objects with NULL inner values will be considered "equal" here.
221          */
222         public boolean eq(org.ldk.structs.ChannelInfo b) {
223                 boolean ret = bindings.ChannelInfo_eq(this.ptr, b == null ? 0 : b.ptr);
224                 Reference.reachabilityFence(this);
225                 Reference.reachabilityFence(b);
226                 if (this != null) { this.ptrs_to.add(b); };
227                 return ret;
228         }
229
230         @Override public boolean equals(Object o) {
231                 if (!(o instanceof ChannelInfo)) return false;
232                 return this.eq((ChannelInfo)o);
233         }
234         /**
235          * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
236          * 
237          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
238          */
239         @Nullable
240         public ChannelUpdateInfo get_directional_info(byte channel_flags) {
241                 long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags);
242                 Reference.reachabilityFence(this);
243                 Reference.reachabilityFence(channel_flags);
244                 if (ret >= 0 && ret <= 4096) { return null; }
245                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
246                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
247                 return ret_hu_conv;
248         }
249
250         /**
251          * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
252          */
253         public byte[] write() {
254                 byte[] ret = bindings.ChannelInfo_write(this.ptr);
255                 Reference.reachabilityFence(this);
256                 return ret;
257         }
258
259         /**
260          * Read a ChannelInfo from a byte array, created by ChannelInfo_write
261          */
262         public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
263                 long ret = bindings.ChannelInfo_read(ser);
264                 Reference.reachabilityFence(ser);
265                 if (ret >= 0 && ret <= 4096) { return null; }
266                 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
267                 return ret_hu_conv;
268         }
269
270 }