UNPKG

lightningdevkit

Version:
158 lines 6.28 kB
import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs'; import { ChannelId } from '../structs/ChannelId.mjs'; import { Result_ChannelReestablishDecodeErrorZ } from '../structs/Result_ChannelReestablishDecodeErrorZ.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * A [`channel_reestablish`] message to be sent to or received from a peer. * * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission */ export class ChannelReestablish extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.ChannelReestablish_free); } /** * The channel ID */ get_channel_id() { const ret = bindings.ChannelReestablish_get_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 channel ID */ set_channel_id(val) { bindings.ChannelReestablish_set_channel_id(this.ptr, CommonBase.get_ptr_of(val)); } /** * The next commitment number for the sender */ get_next_local_commitment_number() { const ret = bindings.ChannelReestablish_get_next_local_commitment_number(this.ptr); return ret; } /** * The next commitment number for the sender */ set_next_local_commitment_number(val) { bindings.ChannelReestablish_set_next_local_commitment_number(this.ptr, val); } /** * The next commitment number for the recipient */ get_next_remote_commitment_number() { const ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this.ptr); return ret; } /** * The next commitment number for the recipient */ set_next_remote_commitment_number(val) { bindings.ChannelReestablish_set_next_remote_commitment_number(this.ptr, val); } /** * Proof that the sender knows the per-commitment secret of a specific commitment transaction * belonging to the recipient */ get_your_last_per_commitment_secret() { const ret = bindings.ChannelReestablish_get_your_last_per_commitment_secret(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Proof that the sender knows the per-commitment secret of a specific commitment transaction * belonging to the recipient */ set_your_last_per_commitment_secret(val) { bindings.ChannelReestablish_set_your_last_per_commitment_secret(this.ptr, bindings.encodeUint8Array(val)); } /** * The sender's per-commitment point for their current commitment transaction */ get_my_current_per_commitment_point() { const ret = bindings.ChannelReestablish_get_my_current_per_commitment_point(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * The sender's per-commitment point for their current commitment transaction */ set_my_current_per_commitment_point(val) { bindings.ChannelReestablish_set_my_current_per_commitment_point(this.ptr, bindings.encodeUint8Array(val)); } /** * The next funding transaction ID */ get_next_funding_txid() { const ret = bindings.ChannelReestablish_get_next_funding_txid(this.ptr); const ret_hu_conv = Option_ThirtyTwoBytesZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The next funding transaction ID */ set_next_funding_txid(val) { bindings.ChannelReestablish_set_next_funding_txid(this.ptr, CommonBase.get_ptr_of(val)); } /** * Constructs a new ChannelReestablish given each field */ static constructor_new(channel_id_arg, next_local_commitment_number_arg, next_remote_commitment_number_arg, your_last_per_commitment_secret_arg, my_current_per_commitment_point_arg, next_funding_txid_arg) { const ret = bindings.ChannelReestablish_new(CommonBase.get_ptr_of(channel_id_arg), next_local_commitment_number_arg, next_remote_commitment_number_arg, bindings.encodeUint8Array(your_last_per_commitment_secret_arg), bindings.encodeUint8Array(my_current_per_commitment_point_arg), CommonBase.get_ptr_of(next_funding_txid_arg)); const ret_hu_conv = new ChannelReestablish(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.ChannelReestablish_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the ChannelReestablish */ clone() { const ret = bindings.ChannelReestablish_clone(this.ptr); const ret_hu_conv = new ChannelReestablish(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the ChannelReestablish. */ hash() { const ret = bindings.ChannelReestablish_hash(this.ptr); return ret; } /** * Checks if two ChannelReestablishs 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.ChannelReestablish_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } /** * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read */ write() { const ret = bindings.ChannelReestablish_write(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write */ static constructor_read(ser) { const ret = bindings.ChannelReestablish_read(bindings.encodeUint8Array(ser)); const ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } } //# sourceMappingURL=ChannelReestablish.mjs.map