6 namespace org { namespace ldk { namespace structs {
10 * Features used within the channel_type field in an OpenChannel message.
12 * A channel is always of some known \"type\", describing the transaction formats used and the exact
13 * semantics of our interaction with our peer.
15 * Note that because a channel is a specific type which is proposed by the opener and accepted by
16 * the counterparty, only required features are allowed here.
18 * This is serialized differently from other feature types - it is not prefixed by a length, and
19 * thus must only appear inside a TLV where its length is known in advance.
21 public class ChannelTypeFeatures : CommonBase {
22 internal ChannelTypeFeatures(object _dummy, long ptr) : base(ptr) { }
23 ~ChannelTypeFeatures() {
24 if (ptr != 0) { bindings.ChannelTypeFeatures_free(ptr); }
28 * Checks if two ChannelTypeFeaturess contain equal inner contents.
29 * This ignores pointers and is_owned flags and looks at the values in fields.
30 * Two objects with NULL inner values will be considered "equal" here.
32 public bool eq(org.ldk.structs.ChannelTypeFeatures b) {
33 bool ret = bindings.ChannelTypeFeatures_eq(this.ptr, b == null ? 0 : b.ptr);
36 if (this != null) { this.ptrs_to.AddLast(b); };
40 public override bool Equals(object o) {
41 if (!(o is ChannelTypeFeatures)) return false;
42 return this.eq((ChannelTypeFeatures)o);
44 internal long clone_ptr() {
45 long ret = bindings.ChannelTypeFeatures_clone_ptr(this.ptr);
51 * Creates a copy of the ChannelTypeFeatures
53 public ChannelTypeFeatures clone() {
54 long ret = bindings.ChannelTypeFeatures_clone(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
58 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
63 * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures.
66 long ret = bindings.ChannelTypeFeatures_hash(this.ptr);
71 public override int GetHashCode() {
72 return (int)this.hash();
75 * Create a blank Features with no features set
77 public static ChannelTypeFeatures empty() {
78 long ret = bindings.ChannelTypeFeatures_empty();
79 if (ret >= 0 && ret <= 4096) { return null; }
80 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
81 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
86 * Returns true if this `Features` object contains required features unknown by `other`.
88 public bool requires_unknown_bits_from(org.ldk.structs.ChannelTypeFeatures other) {
89 bool ret = bindings.ChannelTypeFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
92 if (this != null) { this.ptrs_to.AddLast(other); };
97 * Returns true if this `Features` object contains unknown feature flags which are set as
100 public bool requires_unknown_bits() {
101 bool ret = bindings.ChannelTypeFeatures_requires_unknown_bits(this.ptr);
107 * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
110 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
111 * be set instead (i.e., `bit - 1`).
113 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
115 public Result_NoneNoneZ set_required_feature_bit(long bit) {
116 long ret = bindings.ChannelTypeFeatures_set_required_feature_bit(this.ptr, bit);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
125 * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
128 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
129 * set instead (i.e., `bit + 1`).
131 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
133 public Result_NoneNoneZ set_optional_feature_bit(long bit) {
134 long ret = bindings.ChannelTypeFeatures_set_optional_feature_bit(this.ptr, bit);
137 if (ret >= 0 && ret <= 4096) { return null; }
138 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
143 * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
144 * by [bLIP 2] or if it is a known `T` feature.
146 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
147 * be set instead (i.e., `bit - 1`).
149 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
151 public Result_NoneNoneZ set_required_custom_bit(long bit) {
152 long ret = bindings.ChannelTypeFeatures_set_required_custom_bit(this.ptr, bit);
155 if (ret >= 0 && ret <= 4096) { return null; }
156 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
161 * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
162 * by [bLIP 2] or if it is a known `T` feature.
164 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
165 * set instead (i.e., `bit + 1`).
167 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
169 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
170 long ret = bindings.ChannelTypeFeatures_set_optional_custom_bit(this.ptr, bit);
173 if (ret >= 0 && ret <= 4096) { return null; }
174 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
179 * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
181 public byte[] write() {
182 long ret = bindings.ChannelTypeFeatures_write(this.ptr);
184 if (ret >= 0 && ret <= 4096) { return null; }
185 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
190 * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
192 public static Result_ChannelTypeFeaturesDecodeErrorZ read(byte[] ser) {
193 long ret = bindings.ChannelTypeFeatures_read(InternalUtils.encodeUint8Array(ser));
195 if (ret >= 0 && ret <= 4096) { return null; }
196 Result_ChannelTypeFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelTypeFeaturesDecodeErrorZ.constr_from_ptr(ret);
201 * Set this feature as optional.
203 public void set_static_remote_key_optional() {
204 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
209 * Set this feature as required.
211 public void set_static_remote_key_required() {
212 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
217 * Checks if this feature is supported.
219 public bool supports_static_remote_key() {
220 bool ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
226 * Checks if this feature is required.
228 public bool requires_static_remote_key() {
229 bool ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
235 * Set this feature as optional.
237 public void set_anchors_nonzero_fee_htlc_tx_optional() {
238 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this.ptr);
243 * Set this feature as required.
245 public void set_anchors_nonzero_fee_htlc_tx_required() {
246 bindings.ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this.ptr);
251 * Checks if this feature is supported.
253 public bool supports_anchors_nonzero_fee_htlc_tx() {
254 bool ret = bindings.ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this.ptr);
260 * Checks if this feature is required.
262 public bool requires_anchors_nonzero_fee_htlc_tx() {
263 bool ret = bindings.ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this.ptr);
269 * Set this feature as optional.
271 public void set_anchors_zero_fee_htlc_tx_optional() {
272 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this.ptr);
277 * Set this feature as required.
279 public void set_anchors_zero_fee_htlc_tx_required() {
280 bindings.ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this.ptr);
285 * Checks if this feature is supported.
287 public bool supports_anchors_zero_fee_htlc_tx() {
288 bool ret = bindings.ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this.ptr);
294 * Checks if this feature is required.
296 public bool requires_anchors_zero_fee_htlc_tx() {
297 bool ret = bindings.ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this.ptr);
303 * Set this feature as optional.
305 public void set_taproot_optional() {
306 bindings.ChannelTypeFeatures_set_taproot_optional(this.ptr);
311 * Set this feature as required.
313 public void set_taproot_required() {
314 bindings.ChannelTypeFeatures_set_taproot_required(this.ptr);
319 * Checks if this feature is supported.
321 public bool supports_taproot() {
322 bool ret = bindings.ChannelTypeFeatures_supports_taproot(this.ptr);
328 * Checks if this feature is required.
330 public bool requires_taproot() {
331 bool ret = bindings.ChannelTypeFeatures_requires_taproot(this.ptr);
337 * Set this feature as optional.
339 public void set_scid_privacy_optional() {
340 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
345 * Set this feature as required.
347 public void set_scid_privacy_required() {
348 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
353 * Checks if this feature is supported.
355 public bool supports_scid_privacy() {
356 bool ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
362 * Checks if this feature is required.
364 public bool requires_scid_privacy() {
365 bool ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
371 * Set this feature as optional.
373 public void set_zero_conf_optional() {
374 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
379 * Set this feature as required.
381 public void set_zero_conf_required() {
382 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
387 * Checks if this feature is supported.
389 public bool supports_zero_conf() {
390 bool ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
396 * Checks if this feature is required.
398 public bool requires_zero_conf() {
399 bool ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);