1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Features used within the channel_type field in an OpenChannel message.
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.
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.
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.
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 {
29 if (ptr != 0) { bindings.ChannelTypeFeatures_free(ptr); }
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.
37 public boolean eq(org.ldk.structs.ChannelTypeFeatures b) {
38 boolean ret = bindings.ChannelTypeFeatures_eq(this.ptr, b.ptr);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(b);
41 if (this != null) { this.ptrs_to.add(b); };
45 @Override public boolean equals(Object o) {
46 if (!(o instanceof ChannelTypeFeatures)) return false;
47 return this.eq((ChannelTypeFeatures)o);
50 long ret = bindings.ChannelTypeFeatures_clone_ptr(this.ptr);
51 Reference.reachabilityFence(this);
56 * Creates a copy of the ChannelTypeFeatures
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); };
68 * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures.
71 long ret = bindings.ChannelTypeFeatures_hash(this.ptr);
72 Reference.reachabilityFence(this);
76 @Override public int hashCode() {
77 return (int)this.hash();
80 * Create a blank Features with no features set
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); };
91 * Returns true if this `Features` object contains required features unknown by `other`.
93 public boolean requires_unknown_bits_from(org.ldk.structs.ChannelTypeFeatures other) {
94 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits_from(this.ptr, other.ptr);
95 Reference.reachabilityFence(this);
96 Reference.reachabilityFence(other);
97 if (this != null) { this.ptrs_to.add(other); };
102 * Returns true if this `Features` object contains unknown feature flags which are set as
105 public boolean requires_unknown_bits() {
106 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits(this.ptr);
107 Reference.reachabilityFence(this);
112 * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
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`).
118 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
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);
130 * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
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`).
136 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
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);
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.
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`).
154 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
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);
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.
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`).
172 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
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);
184 * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
186 public byte[] write() {
187 byte[] ret = bindings.ChannelTypeFeatures_write(this.ptr);
188 Reference.reachabilityFence(this);
193 * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
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);
204 * Set this feature as optional.
206 public void set_static_remote_key_optional() {
207 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
208 Reference.reachabilityFence(this);
212 * Set this feature as required.
214 public void set_static_remote_key_required() {
215 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
216 Reference.reachabilityFence(this);
220 * Checks if this feature is supported.
222 public boolean supports_static_remote_key() {
223 boolean ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
224 Reference.reachabilityFence(this);
229 * Checks if this feature is required.
231 public boolean requires_static_remote_key() {
232 boolean ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
233 Reference.reachabilityFence(this);
238 * Set this feature as optional.
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);
246 * Set this feature as required.
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);
254 * Checks if this feature is supported.
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);
263 * Checks if this feature is required.
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);
272 * Set this feature as optional.
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);
280 * Set this feature as required.
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);
288 * Checks if this feature is supported.
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);
297 * Checks if this feature is required.
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);
306 * Set this feature as optional.
308 public void set_taproot_optional() {
309 bindings.ChannelTypeFeatures_set_taproot_optional(this.ptr);
310 Reference.reachabilityFence(this);
314 * Set this feature as required.
316 public void set_taproot_required() {
317 bindings.ChannelTypeFeatures_set_taproot_required(this.ptr);
318 Reference.reachabilityFence(this);
322 * Checks if this feature is supported.
324 public boolean supports_taproot() {
325 boolean ret = bindings.ChannelTypeFeatures_supports_taproot(this.ptr);
326 Reference.reachabilityFence(this);
331 * Checks if this feature is required.
333 public boolean requires_taproot() {
334 boolean ret = bindings.ChannelTypeFeatures_requires_taproot(this.ptr);
335 Reference.reachabilityFence(this);
340 * Set this feature as optional.
342 public void set_scid_privacy_optional() {
343 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
344 Reference.reachabilityFence(this);
348 * Set this feature as required.
350 public void set_scid_privacy_required() {
351 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
352 Reference.reachabilityFence(this);
356 * Checks if this feature is supported.
358 public boolean supports_scid_privacy() {
359 boolean ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
360 Reference.reachabilityFence(this);
365 * Checks if this feature is required.
367 public boolean requires_scid_privacy() {
368 boolean ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
369 Reference.reachabilityFence(this);
374 * Set this feature as optional.
376 public void set_zero_conf_optional() {
377 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
378 Reference.reachabilityFence(this);
382 * Set this feature as required.
384 public void set_zero_conf_required() {
385 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
386 Reference.reachabilityFence(this);
390 * Checks if this feature is supported.
392 public boolean supports_zero_conf() {
393 boolean ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
394 Reference.reachabilityFence(this);
399 * Checks if this feature is required.
401 public boolean requires_zero_conf() {
402 boolean ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);
403 Reference.reachabilityFence(this);