lightningdevkit
Version:
Lightning Development Kit
110 lines • 4.1 kB
JavaScript
import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs';
import { OutPoint } from '../structs/OutPoint.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
*
* Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
* spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
* [`Confirm::transactions_confirmed`].
*
* If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
* may have been spent there. See [`Filter::register_output`] for details.
*
* Depending on your block source, you may need one or both of either [`Self::outpoint`] or
* [`Self::script_pubkey`].
*
* [`ChannelMonitor`]: channelmonitor::ChannelMonitor
* [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
*/
export class WatchedOutput extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.WatchedOutput_free);
}
/**
* First block where the transaction output may have been spent.
*/
get_block_hash() {
const ret = bindings.WatchedOutput_get_block_hash(this.ptr);
const ret_hu_conv = Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* First block where the transaction output may have been spent.
*/
set_block_hash(val) {
bindings.WatchedOutput_set_block_hash(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Outpoint identifying the transaction output.
*/
get_outpoint() {
const ret = bindings.WatchedOutput_get_outpoint(this.ptr);
const ret_hu_conv = new OutPoint(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Outpoint identifying the transaction output.
*/
set_outpoint(val) {
bindings.WatchedOutput_set_outpoint(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Spending condition of the transaction output.
*/
get_script_pubkey() {
const ret = bindings.WatchedOutput_get_script_pubkey(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Spending condition of the transaction output.
*/
set_script_pubkey(val) {
bindings.WatchedOutput_set_script_pubkey(this.ptr, bindings.encodeUint8Array(val));
}
/**
* Constructs a new WatchedOutput given each field
*/
static constructor_new(block_hash_arg, outpoint_arg, script_pubkey_arg) {
const ret = bindings.WatchedOutput_new(CommonBase.get_ptr_of(block_hash_arg), CommonBase.get_ptr_of(outpoint_arg), bindings.encodeUint8Array(script_pubkey_arg));
const ret_hu_conv = new WatchedOutput(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.WatchedOutput_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the WatchedOutput
*/
clone() {
const ret = bindings.WatchedOutput_clone(this.ptr);
const ret_hu_conv = new WatchedOutput(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Checks if two WatchedOutputs 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.WatchedOutput_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Generates a non-cryptographic 64-bit hash of the WatchedOutput.
*/
hash() {
const ret = bindings.WatchedOutput_hash(this.ptr);
return ret;
}
}
//# sourceMappingURL=WatchedOutput.mjs.map