[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ChannelTypeFeatures.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  * Features used within the channel_type field in an OpenChannel message.
13  * 
14  * A channel is always of some known \"type\", describing the transaction formats used and the exact
15  * semantics of our interaction with our peer.
16  * 
17  * Note that because a channel is a specific type which is proposed by the opener and accepted by
18  * the counterparty, only required features are allowed here.
19  * 
20  * This is serialized differently from other feature types - it is not prefixed by a length, and
21  * thus must only appear inside a TLV where its length is known in advance.
22  */
23 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
24 public class ChannelTypeFeatures extends CommonBase {
25         ChannelTypeFeatures(Object _dummy, long ptr) { super(ptr); }
26         @Override @SuppressWarnings("deprecation")
27         protected void finalize() throws Throwable {
28                 super.finalize();
29                 if (ptr != 0) { bindings.ChannelTypeFeatures_free(ptr); }
30         }
31
32         /**
33          * Checks if two ChannelTypeFeaturess contain equal inner contents.
34          * This ignores pointers and is_owned flags and looks at the values in fields.
35          * Two objects with NULL inner values will be considered "equal" here.
36          */
37         public boolean eq(org.ldk.structs.ChannelTypeFeatures b) {
38                 boolean ret = bindings.ChannelTypeFeatures_eq(this.ptr, b == null ? 0 : b.ptr);
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(b);
41                 if (this != null) { this.ptrs_to.add(b); };
42                 return ret;
43         }
44
45         @Override public boolean equals(Object o) {
46                 if (!(o instanceof ChannelTypeFeatures)) return false;
47                 return this.eq((ChannelTypeFeatures)o);
48         }
49         long clone_ptr() {
50                 long ret = bindings.ChannelTypeFeatures_clone_ptr(this.ptr);
51                 Reference.reachabilityFence(this);
52                 return ret;
53         }
54
55         /**
56          * Creates a copy of the ChannelTypeFeatures
57          */
58         public ChannelTypeFeatures clone() {
59                 long ret = bindings.ChannelTypeFeatures_clone(this.ptr);
60                 Reference.reachabilityFence(this);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
63                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
64                 return ret_hu_conv;
65         }
66
67         /**
68          * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures.
69          */
70         public long hash() {
71                 long ret = bindings.ChannelTypeFeatures_hash(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         @Override public int hashCode() {
77                 return (int)this.hash();
78         }
79         /**
80          * Create a blank Features with no features set
81          */
82         public static ChannelTypeFeatures empty() {
83                 long ret = bindings.ChannelTypeFeatures_empty();
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Returns true if this `Features` object contains required features unknown by `other`.
92          */
93         public boolean requires_unknown_bits_from(org.ldk.structs.ChannelTypeFeatures other) {
94                 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
95                 Reference.reachabilityFence(this);
96                 Reference.reachabilityFence(other);
97                 if (this != null) { this.ptrs_to.add(other); };
98                 return ret;
99         }
100
101         /**
102          * Returns true if this `Features` object contains unknown feature flags which are set as
103          * \"required\".
104          */
105         public boolean requires_unknown_bits() {
106                 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
113          * by [BOLT 9].
114          * 
115          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
116          * be set instead (i.e., `bit - 1`).
117          * 
118          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
119          */
120         public Result_NoneNoneZ set_required_feature_bit(long bit) {
121                 long ret = bindings.ChannelTypeFeatures_set_required_feature_bit(this.ptr, bit);
122                 Reference.reachabilityFence(this);
123                 Reference.reachabilityFence(bit);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
131          * by [BOLT 9].
132          * 
133          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
134          * set instead (i.e., `bit + 1`).
135          * 
136          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
137          */
138         public Result_NoneNoneZ set_optional_feature_bit(long bit) {
139                 long ret = bindings.ChannelTypeFeatures_set_optional_feature_bit(this.ptr, bit);
140                 Reference.reachabilityFence(this);
141                 Reference.reachabilityFence(bit);
142                 if (ret >= 0 && ret <= 4096) { return null; }
143                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
144                 return ret_hu_conv;
145         }
146
147         /**
148          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
149          * by [bLIP 2] or if it is a known `T` feature.
150          * 
151          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
152          * be set instead (i.e., `bit - 1`).
153          * 
154          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
155          */
156         public Result_NoneNoneZ set_required_custom_bit(long bit) {
157                 long ret = bindings.ChannelTypeFeatures_set_required_custom_bit(this.ptr, bit);
158                 Reference.reachabilityFence(this);
159                 Reference.reachabilityFence(bit);
160                 if (ret >= 0 && ret <= 4096) { return null; }
161                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
162                 return ret_hu_conv;
163         }
164
165         /**
166          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
167          * by [bLIP 2] or if it is a known `T` feature.
168          * 
169          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
170          * set instead (i.e., `bit + 1`).
171          * 
172          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
173          */
174         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
175                 long ret = bindings.ChannelTypeFeatures_set_optional_custom_bit(this.ptr, bit);
176                 Reference.reachabilityFence(this);
177                 Reference.reachabilityFence(bit);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
180                 return ret_hu_conv;
181         }
182
183         /**
184          * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
185          */
186         public byte[] write() {
187                 byte[] ret = bindings.ChannelTypeFeatures_write(this.ptr);
188                 Reference.reachabilityFence(this);
189                 return ret;
190         }
191
192         /**
193          * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
194          */
195         public static Result_ChannelTypeFeaturesDecodeErrorZ read(byte[] ser) {
196                 long ret = bindings.ChannelTypeFeatures_read(ser);
197                 Reference.reachabilityFence(ser);
198                 if (ret >= 0 && ret <= 4096) { return null; }
199                 Result_ChannelTypeFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelTypeFeaturesDecodeErrorZ.constr_from_ptr(ret);
200                 return ret_hu_conv;
201         }
202
203         /**
204          * Set this feature as optional.
205          */
206         public void set_static_remote_key_optional() {
207                 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
208                 Reference.reachabilityFence(this);
209         }
210
211         /**
212          * Set this feature as required.
213          */
214         public void set_static_remote_key_required() {
215                 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
216                 Reference.reachabilityFence(this);
217         }
218
219         /**
220          * Checks if this feature is supported.
221          */
222         public boolean supports_static_remote_key() {
223                 boolean ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
224                 Reference.reachabilityFence(this);
225                 return ret;
226         }
227
228         /**
229          * Checks if this feature is required.
230          */
231         public boolean requires_static_remote_key() {
232                 boolean ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
233                 Reference.reachabilityFence(this);
234                 return ret;
235         }
236
237         /**
238          * Set this feature as optional.
239          */
240         public void set_anchors_nonzero_fee_htlc_tx_optional() {
241                 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this.ptr);
242                 Reference.reachabilityFence(this);
243         }
244
245         /**
246          * Set this feature as required.
247          */
248         public void set_anchors_nonzero_fee_htlc_tx_required() {
249                 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this.ptr);
250                 Reference.reachabilityFence(this);
251         }
252
253         /**
254          * Checks if this feature is supported.
255          */
256         public boolean supports_anchors_nonzero_fee_htlc_tx() {
257                 boolean ret = bindings.ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this.ptr);
258                 Reference.reachabilityFence(this);
259                 return ret;
260         }
261
262         /**
263          * Checks if this feature is required.
264          */
265         public boolean requires_anchors_nonzero_fee_htlc_tx() {
266                 boolean ret = bindings.ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this.ptr);
267                 Reference.reachabilityFence(this);
268                 return ret;
269         }
270
271         /**
272          * Set this feature as optional.
273          */
274         public void set_anchors_zero_fee_htlc_tx_optional() {
275                 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this.ptr);
276                 Reference.reachabilityFence(this);
277         }
278
279         /**
280          * Set this feature as required.
281          */
282         public void set_anchors_zero_fee_htlc_tx_required() {
283                 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this.ptr);
284                 Reference.reachabilityFence(this);
285         }
286
287         /**
288          * Checks if this feature is supported.
289          */
290         public boolean supports_anchors_zero_fee_htlc_tx() {
291                 boolean ret = bindings.ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this.ptr);
292                 Reference.reachabilityFence(this);
293                 return ret;
294         }
295
296         /**
297          * Checks if this feature is required.
298          */
299         public boolean requires_anchors_zero_fee_htlc_tx() {
300                 boolean ret = bindings.ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this.ptr);
301                 Reference.reachabilityFence(this);
302                 return ret;
303         }
304
305         /**
306          * Set this feature as optional.
307          */
308         public void set_taproot_optional() {
309                 bindings.ChannelTypeFeatures_set_taproot_optional(this.ptr);
310                 Reference.reachabilityFence(this);
311         }
312
313         /**
314          * Set this feature as required.
315          */
316         public void set_taproot_required() {
317                 bindings.ChannelTypeFeatures_set_taproot_required(this.ptr);
318                 Reference.reachabilityFence(this);
319         }
320
321         /**
322          * Checks if this feature is supported.
323          */
324         public boolean supports_taproot() {
325                 boolean ret = bindings.ChannelTypeFeatures_supports_taproot(this.ptr);
326                 Reference.reachabilityFence(this);
327                 return ret;
328         }
329
330         /**
331          * Checks if this feature is required.
332          */
333         public boolean requires_taproot() {
334                 boolean ret = bindings.ChannelTypeFeatures_requires_taproot(this.ptr);
335                 Reference.reachabilityFence(this);
336                 return ret;
337         }
338
339         /**
340          * Set this feature as optional.
341          */
342         public void set_scid_privacy_optional() {
343                 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
344                 Reference.reachabilityFence(this);
345         }
346
347         /**
348          * Set this feature as required.
349          */
350         public void set_scid_privacy_required() {
351                 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
352                 Reference.reachabilityFence(this);
353         }
354
355         /**
356          * Checks if this feature is supported.
357          */
358         public boolean supports_scid_privacy() {
359                 boolean ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
360                 Reference.reachabilityFence(this);
361                 return ret;
362         }
363
364         /**
365          * Checks if this feature is required.
366          */
367         public boolean requires_scid_privacy() {
368                 boolean ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
369                 Reference.reachabilityFence(this);
370                 return ret;
371         }
372
373         /**
374          * Set this feature as optional.
375          */
376         public void set_zero_conf_optional() {
377                 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
378                 Reference.reachabilityFence(this);
379         }
380
381         /**
382          * Set this feature as required.
383          */
384         public void set_zero_conf_required() {
385                 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
386                 Reference.reachabilityFence(this);
387         }
388
389         /**
390          * Checks if this feature is supported.
391          */
392         public boolean supports_zero_conf() {
393                 boolean ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
394                 Reference.reachabilityFence(this);
395                 return ret;
396         }
397
398         /**
399          * Checks if this feature is required.
400          */
401         public boolean requires_zero_conf() {
402                 boolean ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);
403                 Reference.reachabilityFence(this);
404                 return ret;
405         }
406
407 }