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
8
9 /**
10  * Details about a channel (both directions).
11  * Received within a channel announcement.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ChannelInfo extends CommonBase {
15         ChannelInfo(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ChannelInfo_free(ptr); }
20         }
21
22         /**
23          * Protocol features of a channel communicated during its announcement
24          */
25         public ChannelFeatures get_features() {
26                 long ret = bindings.ChannelInfo_get_features(this.ptr);
27                 if (ret < 1024) { return null; }
28                 ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
29                 ret_hu_conv.ptrs_to.add(this);
30                 return ret_hu_conv;
31         }
32
33         /**
34          * Protocol features of a channel communicated during its announcement
35          */
36         public void set_features(ChannelFeatures val) {
37                 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
38                 this.ptrs_to.add(val);
39         }
40
41         /**
42          * Source node of the first direction of a channel
43          */
44         public byte[] get_node_one() {
45                 byte[] ret = bindings.ChannelInfo_get_node_one(this.ptr);
46                 return ret;
47         }
48
49         /**
50          * Source node of the first direction of a channel
51          */
52         public void set_node_one(byte[] val) {
53                 bindings.ChannelInfo_set_node_one(this.ptr, val);
54         }
55
56         /**
57          * Details about the first direction of a channel
58          * 
59          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
60          */
61         @Nullable
62         public DirectionalChannelInfo get_one_to_two() {
63                 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
64                 if (ret < 1024) { return null; }
65                 DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
66                 ret_hu_conv.ptrs_to.add(this);
67                 return ret_hu_conv;
68         }
69
70         /**
71          * Details about the first direction of a channel
72          * 
73          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
74          */
75         public void set_one_to_two(@Nullable DirectionalChannelInfo val) {
76                 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1);
77                 this.ptrs_to.add(val);
78         }
79
80         /**
81          * Source node of the second direction of a channel
82          */
83         public byte[] get_node_two() {
84                 byte[] ret = bindings.ChannelInfo_get_node_two(this.ptr);
85                 return ret;
86         }
87
88         /**
89          * Source node of the second direction of a channel
90          */
91         public void set_node_two(byte[] val) {
92                 bindings.ChannelInfo_set_node_two(this.ptr, val);
93         }
94
95         /**
96          * Details about the second direction of a channel
97          * 
98          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
99          */
100         @Nullable
101         public DirectionalChannelInfo get_two_to_one() {
102                 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
103                 if (ret < 1024) { return null; }
104                 DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
105                 ret_hu_conv.ptrs_to.add(this);
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Details about the second direction of a channel
111          * 
112          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
113          */
114         public void set_two_to_one(@Nullable DirectionalChannelInfo val) {
115                 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1);
116                 this.ptrs_to.add(val);
117         }
118
119         /**
120          * The channel capacity as seen on-chain, if chain lookup is available.
121          */
122         public Option_u64Z get_capacity_sats() {
123                 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
124                 if (ret < 1024) { return null; }
125                 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
126                 ret_hu_conv.ptrs_to.add(this);
127                 return ret_hu_conv;
128         }
129
130         /**
131          * The channel capacity as seen on-chain, if chain lookup is available.
132          */
133         public void set_capacity_sats(Option_u64Z val) {
134                 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
135         }
136
137         /**
138          * An initial announcement of the channel
139          * Mostly redundant with the data we store in fields explicitly.
140          * Everything else is useful only for sending out for initial routing sync.
141          * Not stored if contains excess data to prevent DoS.
142          * 
143          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
144          */
145         @Nullable
146         public ChannelAnnouncement get_announcement_message() {
147                 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
148                 if (ret < 1024) { return null; }
149                 ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
150                 ret_hu_conv.ptrs_to.add(this);
151                 return ret_hu_conv;
152         }
153
154         /**
155          * An initial announcement of the channel
156          * Mostly redundant with the data we store in fields explicitly.
157          * Everything else is useful only for sending out for initial routing sync.
158          * Not stored if contains excess data to prevent DoS.
159          * 
160          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
161          */
162         public void set_announcement_message(@Nullable ChannelAnnouncement val) {
163                 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
164                 this.ptrs_to.add(val);
165         }
166
167         /**
168          * Constructs a new ChannelInfo given each field
169          */
170         public static ChannelInfo of(ChannelFeatures features_arg, byte[] node_one_arg, DirectionalChannelInfo one_to_two_arg, byte[] node_two_arg, DirectionalChannelInfo two_to_one_arg, Option_u64Z capacity_sats_arg, ChannelAnnouncement announcement_message_arg) {
171                 long ret = bindings.ChannelInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, node_one_arg, one_to_two_arg == null ? 0 : one_to_two_arg.ptr & ~1, node_two_arg, two_to_one_arg == null ? 0 : two_to_one_arg.ptr & ~1, capacity_sats_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
172                 if (ret < 1024) { return null; }
173                 ChannelInfo ret_hu_conv = new ChannelInfo(null, ret);
174                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
175                 ret_hu_conv.ptrs_to.add(features_arg);
176                 ret_hu_conv.ptrs_to.add(one_to_two_arg);
177                 ret_hu_conv.ptrs_to.add(two_to_one_arg);
178                 ret_hu_conv.ptrs_to.add(announcement_message_arg);
179                 return ret_hu_conv;
180         }
181
182         /**
183          * Creates a copy of the ChannelInfo
184          */
185         public ChannelInfo clone() {
186                 long ret = bindings.ChannelInfo_clone(this.ptr);
187                 if (ret < 1024) { return null; }
188                 ChannelInfo ret_hu_conv = new ChannelInfo(null, ret);
189                 ret_hu_conv.ptrs_to.add(this);
190                 return ret_hu_conv;
191         }
192
193         /**
194          * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
195          */
196         public byte[] write() {
197                 byte[] ret = bindings.ChannelInfo_write(this.ptr);
198                 return ret;
199         }
200
201         /**
202          * Read a ChannelInfo from a byte array, created by ChannelInfo_write
203          */
204         public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
205                 long ret = bindings.ChannelInfo_read(ser);
206                 if (ret < 1024) { return null; }
207                 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
208                 return ret_hu_conv;
209         }
210
211 }