UNPKG

lightningdevkit

Version:
288 lines 12.5 kB
import { Option_CVec_u8ZZ } from '../structs/Option_CVec_u8ZZ.mjs'; import { ChannelId } from '../structs/ChannelId.mjs'; import { ChannelTypeFeatures } from '../structs/ChannelTypeFeatures.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * Contains fields that are both common to [`accept_channel`] and [`accept_channel2`] messages. * * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message * [`accept_channel2`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel2-message */ export class CommonAcceptChannelFields extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.CommonAcceptChannelFields_free); } /** * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. */ get_temporary_channel_id() { const ret = bindings.CommonAcceptChannelFields_get_temporary_channel_id(this.ptr); const ret_hu_conv = new ChannelId(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. */ set_temporary_channel_id(val) { bindings.CommonAcceptChannelFields_set_temporary_channel_id(this.ptr, CommonBase.get_ptr_of(val)); } /** * The threshold below which outputs on transactions broadcast by the channel acceptor will be * omitted */ get_dust_limit_satoshis() { const ret = bindings.CommonAcceptChannelFields_get_dust_limit_satoshis(this.ptr); return ret; } /** * The threshold below which outputs on transactions broadcast by the channel acceptor will be * omitted */ set_dust_limit_satoshis(val) { bindings.CommonAcceptChannelFields_set_dust_limit_satoshis(this.ptr, val); } /** * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ get_max_htlc_value_in_flight_msat() { const ret = bindings.CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(this.ptr); return ret; } /** * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ set_max_htlc_value_in_flight_msat(val) { bindings.CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(this.ptr, val); } /** * The minimum HTLC size incoming to channel acceptor, in milli-satoshi */ get_htlc_minimum_msat() { const ret = bindings.CommonAcceptChannelFields_get_htlc_minimum_msat(this.ptr); return ret; } /** * The minimum HTLC size incoming to channel acceptor, in milli-satoshi */ set_htlc_minimum_msat(val) { bindings.CommonAcceptChannelFields_set_htlc_minimum_msat(this.ptr, val); } /** * Minimum depth of the funding transaction before the channel is considered open */ get_minimum_depth() { const ret = bindings.CommonAcceptChannelFields_get_minimum_depth(this.ptr); return ret; } /** * Minimum depth of the funding transaction before the channel is considered open */ set_minimum_depth(val) { bindings.CommonAcceptChannelFields_set_minimum_depth(this.ptr, val); } /** * The number of blocks which the counterparty will have to wait to claim on-chain funds if they * broadcast a commitment transaction */ get_to_self_delay() { const ret = bindings.CommonAcceptChannelFields_get_to_self_delay(this.ptr); return ret; } /** * The number of blocks which the counterparty will have to wait to claim on-chain funds if they * broadcast a commitment transaction */ set_to_self_delay(val) { bindings.CommonAcceptChannelFields_set_to_self_delay(this.ptr, val); } /** * The maximum number of inbound HTLCs towards channel acceptor */ get_max_accepted_htlcs() { const ret = bindings.CommonAcceptChannelFields_get_max_accepted_htlcs(this.ptr); return ret; } /** * The maximum number of inbound HTLCs towards channel acceptor */ set_max_accepted_htlcs(val) { bindings.CommonAcceptChannelFields_set_max_accepted_htlcs(this.ptr, val); } /** * The channel acceptor's key controlling the funding transaction */ get_funding_pubkey() { const ret = bindings.CommonAcceptChannelFields_get_funding_pubkey(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * The channel acceptor's key controlling the funding transaction */ set_funding_pubkey(val) { bindings.CommonAcceptChannelFields_set_funding_pubkey(this.ptr, bindings.encodeUint8Array(val)); } /** * Used to derive a revocation key for transactions broadcast by counterparty */ get_revocation_basepoint() { const ret = bindings.CommonAcceptChannelFields_get_revocation_basepoint(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Used to derive a revocation key for transactions broadcast by counterparty */ set_revocation_basepoint(val) { bindings.CommonAcceptChannelFields_set_revocation_basepoint(this.ptr, bindings.encodeUint8Array(val)); } /** * A payment key to channel acceptor for transactions broadcast by counterparty */ get_payment_basepoint() { const ret = bindings.CommonAcceptChannelFields_get_payment_basepoint(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * A payment key to channel acceptor for transactions broadcast by counterparty */ set_payment_basepoint(val) { bindings.CommonAcceptChannelFields_set_payment_basepoint(this.ptr, bindings.encodeUint8Array(val)); } /** * Used to derive a payment key to channel acceptor for transactions broadcast by channel * acceptor */ get_delayed_payment_basepoint() { const ret = bindings.CommonAcceptChannelFields_get_delayed_payment_basepoint(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Used to derive a payment key to channel acceptor for transactions broadcast by channel * acceptor */ set_delayed_payment_basepoint(val) { bindings.CommonAcceptChannelFields_set_delayed_payment_basepoint(this.ptr, bindings.encodeUint8Array(val)); } /** * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty */ get_htlc_basepoint() { const ret = bindings.CommonAcceptChannelFields_get_htlc_basepoint(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty */ set_htlc_basepoint(val) { bindings.CommonAcceptChannelFields_set_htlc_basepoint(this.ptr, bindings.encodeUint8Array(val)); } /** * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point */ get_first_per_commitment_point() { const ret = bindings.CommonAcceptChannelFields_get_first_per_commitment_point(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point */ set_first_per_commitment_point(val) { bindings.CommonAcceptChannelFields_set_first_per_commitment_point(this.ptr, bindings.encodeUint8Array(val)); } /** * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we * collaboratively close */ get_shutdown_scriptpubkey() { const ret = bindings.CommonAcceptChannelFields_get_shutdown_scriptpubkey(this.ptr); const ret_hu_conv = Option_CVec_u8ZZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we * collaboratively close */ set_shutdown_scriptpubkey(val) { bindings.CommonAcceptChannelFields_set_shutdown_scriptpubkey(this.ptr, CommonBase.get_ptr_of(val)); } /** * The channel type that this channel will represent. If none is set, we derive the channel * type from the intersection of our feature bits with our counterparty's feature bits from * the Init message. * * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s * [`CommonOpenChannelFields::channel_type`]. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ get_channel_type() { const ret = bindings.CommonAcceptChannelFields_get_channel_type(this.ptr); const ret_hu_conv = new ChannelTypeFeatures(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The channel type that this channel will represent. If none is set, we derive the channel * type from the intersection of our feature bits with our counterparty's feature bits from * the Init message. * * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s * [`CommonOpenChannelFields::channel_type`]. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ set_channel_type(val) { bindings.CommonAcceptChannelFields_set_channel_type(this.ptr, val == null ? 0n : CommonBase.get_ptr_of(val)); } /** * Constructs a new CommonAcceptChannelFields given each field * * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ static constructor_new(temporary_channel_id_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, funding_pubkey_arg, revocation_basepoint_arg, payment_basepoint_arg, delayed_payment_basepoint_arg, htlc_basepoint_arg, first_per_commitment_point_arg, shutdown_scriptpubkey_arg, channel_type_arg) { const ret = bindings.CommonAcceptChannelFields_new(CommonBase.get_ptr_of(temporary_channel_id_arg), dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, bindings.encodeUint8Array(funding_pubkey_arg), bindings.encodeUint8Array(revocation_basepoint_arg), bindings.encodeUint8Array(payment_basepoint_arg), bindings.encodeUint8Array(delayed_payment_basepoint_arg), bindings.encodeUint8Array(htlc_basepoint_arg), bindings.encodeUint8Array(first_per_commitment_point_arg), CommonBase.get_ptr_of(shutdown_scriptpubkey_arg), channel_type_arg == null ? 0n : CommonBase.get_ptr_of(channel_type_arg)); const ret_hu_conv = new CommonAcceptChannelFields(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.CommonAcceptChannelFields_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the CommonAcceptChannelFields */ clone() { const ret = bindings.CommonAcceptChannelFields_clone(this.ptr); const ret_hu_conv = new CommonAcceptChannelFields(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields. */ hash() { const ret = bindings.CommonAcceptChannelFields_hash(this.ptr); return ret; } /** * Checks if two CommonAcceptChannelFieldss 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.CommonAcceptChannelFields_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } } //# sourceMappingURL=CommonAcceptChannelFields.mjs.map