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