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 == null ? 0 : 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 * Create a blank Features with no features set
70 public static ChannelTypeFeatures empty() {
71 long ret = bindings.ChannelTypeFeatures_empty();
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
79 * Returns true if this `Features` object contains required features unknown by `other`.
81 public boolean requires_unknown_bits_from(org.ldk.structs.ChannelTypeFeatures other) {
82 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
83 Reference.reachabilityFence(this);
84 Reference.reachabilityFence(other);
85 if (this != null) { this.ptrs_to.add(other); };
90 * Returns true if this `Features` object contains unknown feature flags which are set as
93 public boolean requires_unknown_bits() {
94 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits(this.ptr);
95 Reference.reachabilityFence(this);
100 * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
103 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
104 * be set instead (i.e., `bit - 1`).
106 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
108 public Result_NoneNoneZ set_required_feature_bit(long bit) {
109 long ret = bindings.ChannelTypeFeatures_set_required_feature_bit(this.ptr, bit);
110 Reference.reachabilityFence(this);
111 Reference.reachabilityFence(bit);
112 if (ret >= 0 && ret <= 4096) { return null; }
113 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
118 * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
121 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
122 * set instead (i.e., `bit + 1`).
124 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
126 public Result_NoneNoneZ set_optional_feature_bit(long bit) {
127 long ret = bindings.ChannelTypeFeatures_set_optional_feature_bit(this.ptr, bit);
128 Reference.reachabilityFence(this);
129 Reference.reachabilityFence(bit);
130 if (ret >= 0 && ret <= 4096) { return null; }
131 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
136 * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
137 * by [bLIP 2] or if it is a known `T` feature.
139 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
140 * be set instead (i.e., `bit - 1`).
142 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
144 public Result_NoneNoneZ set_required_custom_bit(long bit) {
145 long ret = bindings.ChannelTypeFeatures_set_required_custom_bit(this.ptr, bit);
146 Reference.reachabilityFence(this);
147 Reference.reachabilityFence(bit);
148 if (ret >= 0 && ret <= 4096) { return null; }
149 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
154 * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
155 * by [bLIP 2] or if it is a known `T` feature.
157 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
158 * set instead (i.e., `bit + 1`).
160 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
162 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
163 long ret = bindings.ChannelTypeFeatures_set_optional_custom_bit(this.ptr, bit);
164 Reference.reachabilityFence(this);
165 Reference.reachabilityFence(bit);
166 if (ret >= 0 && ret <= 4096) { return null; }
167 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
172 * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
174 public byte[] write() {
175 byte[] ret = bindings.ChannelTypeFeatures_write(this.ptr);
176 Reference.reachabilityFence(this);
181 * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
183 public static Result_ChannelTypeFeaturesDecodeErrorZ read(byte[] ser) {
184 long ret = bindings.ChannelTypeFeatures_read(ser);
185 Reference.reachabilityFence(ser);
186 if (ret >= 0 && ret <= 4096) { return null; }
187 Result_ChannelTypeFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelTypeFeaturesDecodeErrorZ.constr_from_ptr(ret);
192 * Set this feature as optional.
194 public void set_static_remote_key_optional() {
195 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
196 Reference.reachabilityFence(this);
200 * Set this feature as required.
202 public void set_static_remote_key_required() {
203 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
204 Reference.reachabilityFence(this);
208 * Checks if this feature is supported.
210 public boolean supports_static_remote_key() {
211 boolean ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
212 Reference.reachabilityFence(this);
217 * Checks if this feature is required.
219 public boolean requires_static_remote_key() {
220 boolean ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
221 Reference.reachabilityFence(this);
226 * Set this feature as optional.
228 public void set_anchors_nonzero_fee_htlc_tx_optional() {
229 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this.ptr);
230 Reference.reachabilityFence(this);
234 * Set this feature as required.
236 public void set_anchors_nonzero_fee_htlc_tx_required() {
237 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this.ptr);
238 Reference.reachabilityFence(this);
242 * Checks if this feature is supported.
244 public boolean supports_anchors_nonzero_fee_htlc_tx() {
245 boolean ret = bindings.ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this.ptr);
246 Reference.reachabilityFence(this);
251 * Checks if this feature is required.
253 public boolean requires_anchors_nonzero_fee_htlc_tx() {
254 boolean ret = bindings.ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this.ptr);
255 Reference.reachabilityFence(this);
260 * Set this feature as optional.
262 public void set_anchors_zero_fee_htlc_tx_optional() {
263 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this.ptr);
264 Reference.reachabilityFence(this);
268 * Set this feature as required.
270 public void set_anchors_zero_fee_htlc_tx_required() {
271 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this.ptr);
272 Reference.reachabilityFence(this);
276 * Checks if this feature is supported.
278 public boolean supports_anchors_zero_fee_htlc_tx() {
279 boolean ret = bindings.ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this.ptr);
280 Reference.reachabilityFence(this);
285 * Checks if this feature is required.
287 public boolean requires_anchors_zero_fee_htlc_tx() {
288 boolean ret = bindings.ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this.ptr);
289 Reference.reachabilityFence(this);
294 * Set this feature as optional.
296 public void set_taproot_optional() {
297 bindings.ChannelTypeFeatures_set_taproot_optional(this.ptr);
298 Reference.reachabilityFence(this);
302 * Set this feature as required.
304 public void set_taproot_required() {
305 bindings.ChannelTypeFeatures_set_taproot_required(this.ptr);
306 Reference.reachabilityFence(this);
310 * Checks if this feature is supported.
312 public boolean supports_taproot() {
313 boolean ret = bindings.ChannelTypeFeatures_supports_taproot(this.ptr);
314 Reference.reachabilityFence(this);
319 * Checks if this feature is required.
321 public boolean requires_taproot() {
322 boolean ret = bindings.ChannelTypeFeatures_requires_taproot(this.ptr);
323 Reference.reachabilityFence(this);
328 * Set this feature as optional.
330 public void set_scid_privacy_optional() {
331 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
332 Reference.reachabilityFence(this);
336 * Set this feature as required.
338 public void set_scid_privacy_required() {
339 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
340 Reference.reachabilityFence(this);
344 * Checks if this feature is supported.
346 public boolean supports_scid_privacy() {
347 boolean ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
348 Reference.reachabilityFence(this);
353 * Checks if this feature is required.
355 public boolean requires_scid_privacy() {
356 boolean ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
357 Reference.reachabilityFence(this);
362 * Set this feature as optional.
364 public void set_zero_conf_optional() {
365 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
366 Reference.reachabilityFence(this);
370 * Set this feature as required.
372 public void set_zero_conf_required() {
373 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
374 Reference.reachabilityFence(this);
378 * Checks if this feature is supported.
380 public boolean supports_zero_conf() {
381 boolean ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
382 Reference.reachabilityFence(this);
387 * Checks if this feature is required.
389 public boolean requires_zero_conf() {
390 boolean ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);
391 Reference.reachabilityFence(this);