lightningdevkit
Version:
Lightning Development Kit
126 lines • 5.01 kB
JavaScript
import { SpendableOutputDescriptor } from '../structs/SpendableOutputDescriptor.mjs';
import { ChannelId } from '../structs/ChannelId.mjs';
import { Result_TrackedSpendableOutputDecodeErrorZ } from '../structs/Result_TrackedSpendableOutputDecodeErrorZ.mjs';
import { OutputSpendStatus } from '../structs/OutputSpendStatus.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* The state of a spendable output currently tracked by an [`OutputSweeper`].
*/
export class TrackedSpendableOutput extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.TrackedSpendableOutput_free);
}
/**
* The tracked output descriptor.
*/
get_descriptor() {
const ret = bindings.TrackedSpendableOutput_get_descriptor(this.ptr);
const ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The tracked output descriptor.
*/
set_descriptor(val) {
bindings.TrackedSpendableOutput_set_descriptor(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* The channel this output belongs to.
*
* Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
*
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
get_channel_id() {
const ret = bindings.TrackedSpendableOutput_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 this output belongs to.
*
* Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
*
* Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
set_channel_id(val) {
bindings.TrackedSpendableOutput_set_channel_id(this.ptr, val == null ? 0n : CommonBase.get_ptr_of(val));
}
/**
* The current status of the output spend.
*/
get_status() {
const ret = bindings.TrackedSpendableOutput_get_status(this.ptr);
const ret_hu_conv = OutputSpendStatus.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* The current status of the output spend.
*/
set_status(val) {
bindings.TrackedSpendableOutput_set_status(this.ptr, CommonBase.get_ptr_of(val));
}
/**
* Constructs a new TrackedSpendableOutput given each field
*
* Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
static constructor_new(descriptor_arg, channel_id_arg, status_arg) {
const ret = bindings.TrackedSpendableOutput_new(CommonBase.get_ptr_of(descriptor_arg), channel_id_arg == null ? 0n : CommonBase.get_ptr_of(channel_id_arg), CommonBase.get_ptr_of(status_arg));
const ret_hu_conv = new TrackedSpendableOutput(null, ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
clone_ptr() {
const ret = bindings.TrackedSpendableOutput_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the TrackedSpendableOutput
*/
clone() {
const ret = bindings.TrackedSpendableOutput_clone(this.ptr);
const ret_hu_conv = new TrackedSpendableOutput(null, ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Checks if two TrackedSpendableOutputs 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.TrackedSpendableOutput_eq(this.ptr, CommonBase.get_ptr_of(b));
CommonBase.add_ref_from(this, b);
return ret;
}
/**
* Returns whether the output is spent in the given transaction.
*/
is_spent_in(tx) {
const ret = bindings.TrackedSpendableOutput_is_spent_in(this.ptr, bindings.encodeUint8Array(tx));
return ret;
}
/**
* Serialize the TrackedSpendableOutput object into a byte array which can be read by TrackedSpendableOutput_read
*/
write() {
const ret = bindings.TrackedSpendableOutput_write(this.ptr);
const ret_conv = bindings.decodeUint8Array(ret);
return ret_conv;
}
/**
* Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write
*/
static constructor_read(ser) {
const ret = bindings.TrackedSpendableOutput_read(bindings.encodeUint8Array(ser));
const ret_hu_conv = Result_TrackedSpendableOutputDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=TrackedSpendableOutput.mjs.map