[Java] Update auto-generated bindings
[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                 ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
32                 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(ChannelFeatures val) {
40                 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * Source node of the first direction of a channel
47          */
48         public NodeId get_node_one() {
49                 long ret = bindings.ChannelInfo_get_node_one(this.ptr);
50                 Reference.reachabilityFence(this);
51                 if (ret >= 0 && ret <= 4096) { return null; }
52                 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
53                 ret_hu_conv.ptrs_to.add(this);
54                 return ret_hu_conv;
55         }
56
57         /**
58          * Source node of the first direction of a channel
59          */
60         public void set_node_one(NodeId val) {
61                 bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr & ~1);
62                 Reference.reachabilityFence(this);
63                 Reference.reachabilityFence(val);
64         }
65
66         /**
67          * Details about the first direction of a channel
68          * 
69          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
70          */
71         @Nullable
72         public ChannelUpdateInfo get_one_to_two() {
73                 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
74                 Reference.reachabilityFence(this);
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdateInfo(null, ret); }
77                 ret_hu_conv.ptrs_to.add(this);
78                 return ret_hu_conv;
79         }
80
81         /**
82          * Details about the first direction of a channel
83          * 
84          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
85          */
86         public void set_one_to_two(@Nullable ChannelUpdateInfo val) {
87                 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1);
88                 Reference.reachabilityFence(this);
89                 Reference.reachabilityFence(val);
90         }
91
92         /**
93          * Source node of the second direction of a channel
94          */
95         public NodeId get_node_two() {
96                 long ret = bindings.ChannelInfo_get_node_two(this.ptr);
97                 Reference.reachabilityFence(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
100                 ret_hu_conv.ptrs_to.add(this);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Source node of the second direction of a channel
106          */
107         public void set_node_two(NodeId val) {
108                 bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr & ~1);
109                 Reference.reachabilityFence(this);
110                 Reference.reachabilityFence(val);
111         }
112
113         /**
114          * Details about the second direction of a channel
115          * 
116          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
117          */
118         @Nullable
119         public ChannelUpdateInfo get_two_to_one() {
120                 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
121                 Reference.reachabilityFence(this);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdateInfo(null, ret); }
124                 ret_hu_conv.ptrs_to.add(this);
125                 return ret_hu_conv;
126         }
127
128         /**
129          * Details about the second direction of a channel
130          * 
131          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
132          */
133         public void set_two_to_one(@Nullable ChannelUpdateInfo val) {
134                 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1);
135                 Reference.reachabilityFence(this);
136                 Reference.reachabilityFence(val);
137         }
138
139         /**
140          * The channel capacity as seen on-chain, if chain lookup is available.
141          */
142         public Option_u64Z get_capacity_sats() {
143                 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
144                 Reference.reachabilityFence(this);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
147                 ret_hu_conv.ptrs_to.add(this);
148                 return ret_hu_conv;
149         }
150
151         /**
152          * The channel capacity as seen on-chain, if chain lookup is available.
153          */
154         public void set_capacity_sats(Option_u64Z val) {
155                 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
156                 Reference.reachabilityFence(this);
157                 Reference.reachabilityFence(val);
158         }
159
160         /**
161          * An initial announcement of the channel
162          * Mostly redundant with the data we store in fields explicitly.
163          * Everything else is useful only for sending out for initial routing sync.
164          * Not stored if contains excess data to prevent DoS.
165          * 
166          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
167          */
168         @Nullable
169         public ChannelAnnouncement get_announcement_message() {
170                 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
171                 Reference.reachabilityFence(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelAnnouncement(null, ret); }
174                 ret_hu_conv.ptrs_to.add(this);
175                 return ret_hu_conv;
176         }
177
178         /**
179          * An initial announcement of the channel
180          * Mostly redundant with the data we store in fields explicitly.
181          * Everything else is useful only for sending out for initial routing sync.
182          * Not stored if contains excess data to prevent DoS.
183          * 
184          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
185          */
186         public void set_announcement_message(@Nullable ChannelAnnouncement val) {
187                 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
188                 Reference.reachabilityFence(this);
189                 Reference.reachabilityFence(val);
190         }
191
192         long clone_ptr() {
193                 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
194                 Reference.reachabilityFence(this);
195                 return ret;
196         }
197
198         /**
199          * Creates a copy of the ChannelInfo
200          */
201         public ChannelInfo clone() {
202                 long ret = bindings.ChannelInfo_clone(this.ptr);
203                 Reference.reachabilityFence(this);
204                 if (ret >= 0 && ret <= 4096) { return null; }
205                 ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
206                 ret_hu_conv.ptrs_to.add(this);
207                 return ret_hu_conv;
208         }
209
210         /**
211          * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
212          */
213         public byte[] write() {
214                 byte[] ret = bindings.ChannelInfo_write(this.ptr);
215                 Reference.reachabilityFence(this);
216                 return ret;
217         }
218
219         /**
220          * Read a ChannelInfo from a byte array, created by ChannelInfo_write
221          */
222         public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
223                 long ret = bindings.ChannelInfo_read(ser);
224                 Reference.reachabilityFence(ser);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
227                 return ret_hu_conv;
228         }
229
230 }