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 custom feature bit. Errors if `bit` is outside the custom range as defined
101 * by [bLIP 2] or if it is a known `T` feature.
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 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
108 public Result_NoneNoneZ set_required_custom_bit(long bit) {
109 long ret = bindings.ChannelTypeFeatures_set_required_custom_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 custom feature bit. Errors if `bit` is outside the custom range as defined
119 * by [bLIP 2] or if it is a known `T` feature.
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 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
126 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
127 long ret = bindings.ChannelTypeFeatures_set_optional_custom_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 * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
138 public byte[] write() {
139 byte[] ret = bindings.ChannelTypeFeatures_write(this.ptr);
140 Reference.reachabilityFence(this);
145 * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
147 public static Result_ChannelTypeFeaturesDecodeErrorZ read(byte[] ser) {
148 long ret = bindings.ChannelTypeFeatures_read(ser);
149 Reference.reachabilityFence(ser);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 Result_ChannelTypeFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelTypeFeaturesDecodeErrorZ.constr_from_ptr(ret);
156 * Set this feature as optional.
158 public void set_static_remote_key_optional() {
159 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
160 Reference.reachabilityFence(this);
164 * Set this feature as required.
166 public void set_static_remote_key_required() {
167 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
168 Reference.reachabilityFence(this);
172 * Checks if this feature is supported.
174 public boolean supports_static_remote_key() {
175 boolean ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
176 Reference.reachabilityFence(this);
181 * Checks if this feature is required.
183 public boolean requires_static_remote_key() {
184 boolean ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
185 Reference.reachabilityFence(this);
190 * Set this feature as optional.
192 public void set_anchors_nonzero_fee_htlc_tx_optional() {
193 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this.ptr);
194 Reference.reachabilityFence(this);
198 * Set this feature as required.
200 public void set_anchors_nonzero_fee_htlc_tx_required() {
201 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this.ptr);
202 Reference.reachabilityFence(this);
206 * Checks if this feature is supported.
208 public boolean supports_anchors_nonzero_fee_htlc_tx() {
209 boolean ret = bindings.ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this.ptr);
210 Reference.reachabilityFence(this);
215 * Checks if this feature is required.
217 public boolean requires_anchors_nonzero_fee_htlc_tx() {
218 boolean ret = bindings.ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this.ptr);
219 Reference.reachabilityFence(this);
224 * Set this feature as optional.
226 public void set_anchors_zero_fee_htlc_tx_optional() {
227 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this.ptr);
228 Reference.reachabilityFence(this);
232 * Set this feature as required.
234 public void set_anchors_zero_fee_htlc_tx_required() {
235 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this.ptr);
236 Reference.reachabilityFence(this);
240 * Checks if this feature is supported.
242 public boolean supports_anchors_zero_fee_htlc_tx() {
243 boolean ret = bindings.ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this.ptr);
244 Reference.reachabilityFence(this);
249 * Checks if this feature is required.
251 public boolean requires_anchors_zero_fee_htlc_tx() {
252 boolean ret = bindings.ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this.ptr);
253 Reference.reachabilityFence(this);
258 * Set this feature as optional.
260 public void set_scid_privacy_optional() {
261 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
262 Reference.reachabilityFence(this);
266 * Set this feature as required.
268 public void set_scid_privacy_required() {
269 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
270 Reference.reachabilityFence(this);
274 * Checks if this feature is supported.
276 public boolean supports_scid_privacy() {
277 boolean ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
278 Reference.reachabilityFence(this);
283 * Checks if this feature is required.
285 public boolean requires_scid_privacy() {
286 boolean ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
287 Reference.reachabilityFence(this);
292 * Set this feature as optional.
294 public void set_zero_conf_optional() {
295 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
296 Reference.reachabilityFence(this);
300 * Set this feature as required.
302 public void set_zero_conf_required() {
303 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
304 Reference.reachabilityFence(this);
308 * Checks if this feature is supported.
310 public boolean supports_zero_conf() {
311 boolean ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
312 Reference.reachabilityFence(this);
317 * Checks if this feature is required.
319 public boolean requires_zero_conf() {
320 boolean ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);
321 Reference.reachabilityFence(this);