lightningdevkit
Version:
Lightning Development Kit
104 lines • 3.53 kB
JavaScript
import { ChannelId } from '../structs/ChannelId.mjs';
import { Result_ShutdownDecodeErrorZ } from '../structs/Result_ShutdownDecodeErrorZ.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* A [`shutdown`] message to be sent to or received from a peer.
*
* [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
*/
export class Shutdown extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.Shutdown_free);
}
/**
* The channel ID
*/
get_channel_id() {
const ret = bindings.Shutdown_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.Shutdown_set_channel_id(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The destination of this peer's funds on closing.
*
* Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
*/
get_scriptpubkey() {
const ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* The destination of this peer's funds on closing.
*
* Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
*/
set_scriptpubkey(val) {
bindings.Shutdown_set_scriptpubkey(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new Shutdown given each field
*/
static constructor_new(channel_id_arg, scriptpubkey_arg) {
const ret = bindings.Shutdown_new(CommonBase.get_ptr_of(channel_id_arg), bindings.encodeUint8Array(scriptpubkey_arg));
const ret_hu_conv = new Shutdown(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.Shutdown_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the Shutdown
*/
clone() {
const ret = bindings.Shutdown_clone(this.ptr);
const ret_hu_conv = new Shutdown(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Generates a non-cryptographic 64-bit hash of the Shutdown.
*/
hash() {
const ret = bindings.Shutdown_hash(this.ptr);
return ret;
}
/**
* Checks if two Shutdowns 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.Shutdown_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Serialize the Shutdown object into a byte array which can be read by Shutdown_read
*/
write() {
const ret = bindings.Shutdown_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a Shutdown from a byte array, created by Shutdown_write
*/
static constructor_read(ser) {
const ret = bindings.Shutdown_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=Shutdown.mjs.map