UNPKG

lightningdevkit

Version:
764 lines 23.1 kB
import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs'; import { Result_NodeFeaturesDecodeErrorZ } from '../structs/Result_NodeFeaturesDecodeErrorZ.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * Features used within a `node_announcement` message. */ export class NodeFeatures extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.NodeFeatures_free); } /** * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ write() { const ret = bindings.NodeFeatures_write(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ static constructor_read(ser) { const ret = bindings.NodeFeatures_read(bindings.encodeUint8Array(ser)); const ret_hu_conv = Result_NodeFeaturesDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Checks if two NodeFeaturess contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ eq(b) { const ret = bindings.NodeFeatures_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } clone_ptr() { const ret = bindings.NodeFeatures_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the NodeFeatures */ clone() { const ret = bindings.NodeFeatures_clone(this.ptr); const ret_hu_conv = new NodeFeatures(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the NodeFeatures. */ hash() { const ret = bindings.NodeFeatures_hash(this.ptr); return ret; } /** * Create a blank Features with no features set */ static constructor_empty() { const ret = bindings.NodeFeatures_empty(); const ret_hu_conv = new NodeFeatures(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } /** * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order * from most on-the-wire encodings. */ le_flags() { const ret = bindings.NodeFeatures_le_flags(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Returns true if this `Features` has any optional flags set */ supports_any_optional_bits() { const ret = bindings.NodeFeatures_supports_any_optional_bits(this.ptr); return ret; } /** * Returns true if this `Features` object contains required features unknown by `other`. */ requires_unknown_bits_from(other) { const ret = bindings.NodeFeatures_requires_unknown_bits_from(this.ptr, CommonBase.get_ptr_of(other)); CommonBase.add_ref_from(this, other); return ret; } /** * Returns the set of required features unknown by `other`, as their bit position. */ required_unknown_bits_from(other) { const ret = bindings.NodeFeatures_required_unknown_bits_from(this.ptr, CommonBase.get_ptr_of(other)); const ret_conv = bindings.decodeUint64Array(ret); CommonBase.add_ref_from(this, other); return ret_conv; } /** * Returns true if this `Features` object contains unknown feature flags which are set as * \"required\". */ requires_unknown_bits() { const ret = bindings.NodeFeatures_requires_unknown_bits(this.ptr); return ret; } /** * Returns true if this `Features` supports any bits which we do not know of */ supports_unknown_bits() { const ret = bindings.NodeFeatures_supports_unknown_bits(this.ptr); return ret; } /** * Sets a required feature bit. Errors if `bit` is outside the feature range as defined * by [BOLT 9]. * * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will * be set instead (i.e., `bit - 1`). * * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ set_required_feature_bit(bit) { const ret = bindings.NodeFeatures_set_required_feature_bit(this.ptr, bit); const ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined * by [BOLT 9]. * * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be * set instead (i.e., `bit + 1`). * * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ set_optional_feature_bit(bit) { const ret = bindings.NodeFeatures_set_optional_feature_bit(this.ptr, bit); const ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined * by [bLIP 2] or if it is a known `T` feature. * * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will * be set instead (i.e., `bit - 1`). * * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ set_required_custom_bit(bit) { const ret = bindings.NodeFeatures_set_required_custom_bit(this.ptr, bit); const ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined * by [bLIP 2] or if it is a known `T` feature. * * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be * set instead (i.e., `bit + 1`). * * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ set_optional_custom_bit(bit) { const ret = bindings.NodeFeatures_set_optional_custom_bit(this.ptr, bit); const ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Unsets the `upfront_shutdown_script` feature */ clear_upfront_shutdown_script() { const ret = bindings.NodeFeatures_clear_upfront_shutdown_script(this.ptr); const ret_hu_conv = new NodeFeatures(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Unsets the `shutdown_anysegwit` feature */ clear_shutdown_anysegwit() { const ret = bindings.NodeFeatures_clear_shutdown_anysegwit(this.ptr); const ret_hu_conv = new NodeFeatures(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Unsets the `wumbo` feature */ clear_wumbo() { const ret = bindings.NodeFeatures_clear_wumbo(this.ptr); const ret_hu_conv = new NodeFeatures(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Unsets the `scid_privacy` feature */ clear_scid_privacy() { bindings.NodeFeatures_clear_scid_privacy(this.ptr); } /** * Unsets the `anchors_zero_fee_htlc_tx` feature */ clear_anchors_zero_fee_htlc_tx() { bindings.NodeFeatures_clear_anchors_zero_fee_htlc_tx(this.ptr); } /** * Unsets the `route_blinding` feature */ clear_route_blinding() { bindings.NodeFeatures_clear_route_blinding(this.ptr); } /** * Set this feature as optional. */ set_data_loss_protect_optional() { bindings.NodeFeatures_set_data_loss_protect_optional(this.ptr); } /** * Set this feature as required. */ set_data_loss_protect_required() { bindings.NodeFeatures_set_data_loss_protect_required(this.ptr); } /** * Checks if this feature is supported. */ supports_data_loss_protect() { const ret = bindings.NodeFeatures_supports_data_loss_protect(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_data_loss_protect() { const ret = bindings.NodeFeatures_requires_data_loss_protect(this.ptr); return ret; } /** * Set this feature as optional. */ set_upfront_shutdown_script_optional() { bindings.NodeFeatures_set_upfront_shutdown_script_optional(this.ptr); } /** * Set this feature as required. */ set_upfront_shutdown_script_required() { bindings.NodeFeatures_set_upfront_shutdown_script_required(this.ptr); } /** * Checks if this feature is supported. */ supports_upfront_shutdown_script() { const ret = bindings.NodeFeatures_supports_upfront_shutdown_script(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_upfront_shutdown_script() { const ret = bindings.NodeFeatures_requires_upfront_shutdown_script(this.ptr); return ret; } /** * Set this feature as optional. */ set_gossip_queries_optional() { bindings.NodeFeatures_set_gossip_queries_optional(this.ptr); } /** * Set this feature as required. */ set_gossip_queries_required() { bindings.NodeFeatures_set_gossip_queries_required(this.ptr); } /** * Checks if this feature is supported. */ supports_gossip_queries() { const ret = bindings.NodeFeatures_supports_gossip_queries(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_gossip_queries() { const ret = bindings.NodeFeatures_requires_gossip_queries(this.ptr); return ret; } /** * Set this feature as optional. */ set_variable_length_onion_optional() { bindings.NodeFeatures_set_variable_length_onion_optional(this.ptr); } /** * Set this feature as required. */ set_variable_length_onion_required() { bindings.NodeFeatures_set_variable_length_onion_required(this.ptr); } /** * Checks if this feature is supported. */ supports_variable_length_onion() { const ret = bindings.NodeFeatures_supports_variable_length_onion(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_variable_length_onion() { const ret = bindings.NodeFeatures_requires_variable_length_onion(this.ptr); return ret; } /** * Set this feature as optional. */ set_static_remote_key_optional() { bindings.NodeFeatures_set_static_remote_key_optional(this.ptr); } /** * Set this feature as required. */ set_static_remote_key_required() { bindings.NodeFeatures_set_static_remote_key_required(this.ptr); } /** * Checks if this feature is supported. */ supports_static_remote_key() { const ret = bindings.NodeFeatures_supports_static_remote_key(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_static_remote_key() { const ret = bindings.NodeFeatures_requires_static_remote_key(this.ptr); return ret; } /** * Set this feature as optional. */ set_payment_secret_optional() { bindings.NodeFeatures_set_payment_secret_optional(this.ptr); } /** * Set this feature as required. */ set_payment_secret_required() { bindings.NodeFeatures_set_payment_secret_required(this.ptr); } /** * Checks if this feature is supported. */ supports_payment_secret() { const ret = bindings.NodeFeatures_supports_payment_secret(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_payment_secret() { const ret = bindings.NodeFeatures_requires_payment_secret(this.ptr); return ret; } /** * Set this feature as optional. */ set_basic_mpp_optional() { bindings.NodeFeatures_set_basic_mpp_optional(this.ptr); } /** * Set this feature as required. */ set_basic_mpp_required() { bindings.NodeFeatures_set_basic_mpp_required(this.ptr); } /** * Checks if this feature is supported. */ supports_basic_mpp() { const ret = bindings.NodeFeatures_supports_basic_mpp(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_basic_mpp() { const ret = bindings.NodeFeatures_requires_basic_mpp(this.ptr); return ret; } /** * Set this feature as optional. */ set_wumbo_optional() { bindings.NodeFeatures_set_wumbo_optional(this.ptr); } /** * Set this feature as required. */ set_wumbo_required() { bindings.NodeFeatures_set_wumbo_required(this.ptr); } /** * Checks if this feature is supported. */ supports_wumbo() { const ret = bindings.NodeFeatures_supports_wumbo(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_wumbo() { const ret = bindings.NodeFeatures_requires_wumbo(this.ptr); return ret; } /** * Set this feature as optional. */ set_anchors_nonzero_fee_htlc_tx_optional() { bindings.NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this.ptr); } /** * Set this feature as required. */ set_anchors_nonzero_fee_htlc_tx_required() { bindings.NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this.ptr); } /** * Checks if this feature is supported. */ supports_anchors_nonzero_fee_htlc_tx() { const ret = bindings.NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_anchors_nonzero_fee_htlc_tx() { const ret = bindings.NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(this.ptr); return ret; } /** * Set this feature as optional. */ set_anchors_zero_fee_htlc_tx_optional() { bindings.NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(this.ptr); } /** * Set this feature as required. */ set_anchors_zero_fee_htlc_tx_required() { bindings.NodeFeatures_set_anchors_zero_fee_htlc_tx_required(this.ptr); } /** * Checks if this feature is supported. */ supports_anchors_zero_fee_htlc_tx() { const ret = bindings.NodeFeatures_supports_anchors_zero_fee_htlc_tx(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_anchors_zero_fee_htlc_tx() { const ret = bindings.NodeFeatures_requires_anchors_zero_fee_htlc_tx(this.ptr); return ret; } /** * Set this feature as optional. */ set_route_blinding_optional() { bindings.NodeFeatures_set_route_blinding_optional(this.ptr); } /** * Set this feature as required. */ set_route_blinding_required() { bindings.NodeFeatures_set_route_blinding_required(this.ptr); } /** * Checks if this feature is supported. */ supports_route_blinding() { const ret = bindings.NodeFeatures_supports_route_blinding(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_route_blinding() { const ret = bindings.NodeFeatures_requires_route_blinding(this.ptr); return ret; } /** * Set this feature as optional. */ set_shutdown_any_segwit_optional() { bindings.NodeFeatures_set_shutdown_any_segwit_optional(this.ptr); } /** * Set this feature as required. */ set_shutdown_any_segwit_required() { bindings.NodeFeatures_set_shutdown_any_segwit_required(this.ptr); } /** * Checks if this feature is supported. */ supports_shutdown_anysegwit() { const ret = bindings.NodeFeatures_supports_shutdown_anysegwit(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_shutdown_anysegwit() { const ret = bindings.NodeFeatures_requires_shutdown_anysegwit(this.ptr); return ret; } /** * Set this feature as optional. */ set_dual_fund_optional() { bindings.NodeFeatures_set_dual_fund_optional(this.ptr); } /** * Set this feature as required. */ set_dual_fund_required() { bindings.NodeFeatures_set_dual_fund_required(this.ptr); } /** * Checks if this feature is supported. */ supports_dual_fund() { const ret = bindings.NodeFeatures_supports_dual_fund(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_dual_fund() { const ret = bindings.NodeFeatures_requires_dual_fund(this.ptr); return ret; } /** * Set this feature as optional. */ set_taproot_optional() { bindings.NodeFeatures_set_taproot_optional(this.ptr); } /** * Set this feature as required. */ set_taproot_required() { bindings.NodeFeatures_set_taproot_required(this.ptr); } /** * Checks if this feature is supported. */ supports_taproot() { const ret = bindings.NodeFeatures_supports_taproot(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_taproot() { const ret = bindings.NodeFeatures_requires_taproot(this.ptr); return ret; } /** * Set this feature as optional. */ set_onion_messages_optional() { bindings.NodeFeatures_set_onion_messages_optional(this.ptr); } /** * Set this feature as required. */ set_onion_messages_required() { bindings.NodeFeatures_set_onion_messages_required(this.ptr); } /** * Checks if this feature is supported. */ supports_onion_messages() { const ret = bindings.NodeFeatures_supports_onion_messages(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_onion_messages() { const ret = bindings.NodeFeatures_requires_onion_messages(this.ptr); return ret; } /** * Set this feature as optional. */ set_channel_type_optional() { bindings.NodeFeatures_set_channel_type_optional(this.ptr); } /** * Set this feature as required. */ set_channel_type_required() { bindings.NodeFeatures_set_channel_type_required(this.ptr); } /** * Checks if this feature is supported. */ supports_channel_type() { const ret = bindings.NodeFeatures_supports_channel_type(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_channel_type() { const ret = bindings.NodeFeatures_requires_channel_type(this.ptr); return ret; } /** * Set this feature as optional. */ set_scid_privacy_optional() { bindings.NodeFeatures_set_scid_privacy_optional(this.ptr); } /** * Set this feature as required. */ set_scid_privacy_required() { bindings.NodeFeatures_set_scid_privacy_required(this.ptr); } /** * Checks if this feature is supported. */ supports_scid_privacy() { const ret = bindings.NodeFeatures_supports_scid_privacy(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_scid_privacy() { const ret = bindings.NodeFeatures_requires_scid_privacy(this.ptr); return ret; } /** * Set this feature as optional. */ set_zero_conf_optional() { bindings.NodeFeatures_set_zero_conf_optional(this.ptr); } /** * Set this feature as required. */ set_zero_conf_required() { bindings.NodeFeatures_set_zero_conf_required(this.ptr); } /** * Checks if this feature is supported. */ supports_zero_conf() { const ret = bindings.NodeFeatures_supports_zero_conf(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_zero_conf() { const ret = bindings.NodeFeatures_requires_zero_conf(this.ptr); return ret; } /** * Set this feature as optional. */ set_keysend_optional() { bindings.NodeFeatures_set_keysend_optional(this.ptr); } /** * Set this feature as required. */ set_keysend_required() { bindings.NodeFeatures_set_keysend_required(this.ptr); } /** * Checks if this feature is supported. */ supports_keysend() { const ret = bindings.NodeFeatures_supports_keysend(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_keysend() { const ret = bindings.NodeFeatures_requires_keysend(this.ptr); return ret; } /** * Set this feature as optional. */ set_trampoline_routing_optional() { bindings.NodeFeatures_set_trampoline_routing_optional(this.ptr); } /** * Set this feature as required. */ set_trampoline_routing_required() { bindings.NodeFeatures_set_trampoline_routing_required(this.ptr); } /** * Checks if this feature is supported. */ supports_trampoline_routing() { const ret = bindings.NodeFeatures_supports_trampoline_routing(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_trampoline_routing() { const ret = bindings.NodeFeatures_requires_trampoline_routing(this.ptr); return ret; } /** * Set this feature as optional. */ set_dns_resolution_optional() { bindings.NodeFeatures_set_dns_resolution_optional(this.ptr); } /** * Set this feature as required. */ set_dns_resolution_required() { bindings.NodeFeatures_set_dns_resolution_required(this.ptr); } /** * Checks if this feature is supported. */ supports_dns_resolution() { const ret = bindings.NodeFeatures_supports_dns_resolution(this.ptr); return ret; } /** * Checks if this feature is required. */ requires_dns_resolution() { const ret = bindings.NodeFeatures_requires_dns_resolution(this.ptr); return ret; } } //# sourceMappingURL=NodeFeatures.mjs.map