UNPKG

lightningdevkit

Version:
101 lines 3.45 kB
import { TxOut } from '../structs/TxOut.mjs'; import { OutPoint } from '../structs/OutPoint.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * An input that must be included in a transaction when performing coin selection through * [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it * must have an empty [`TxIn::script_sig`] when spent. */ export class Input extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.Input_free); } /** * The unique identifier of the input. */ get_outpoint() { const ret = bindings.Input_get_outpoint(this.ptr); const ret_hu_conv = new OutPoint(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * The unique identifier of the input. */ set_outpoint(val) { bindings.Input_set_outpoint(this.ptr, CommonBase.get_ptr_of(val)); } /** * The UTXO being spent by the input. */ get_previous_utxo() { const ret = bindings.Input_get_previous_utxo(this.ptr); const ret_conv = new TxOut(null, ret); return ret_conv; } /** * The UTXO being spent by the input. */ set_previous_utxo(val) { bindings.Input_set_previous_utxo(this.ptr, CommonBase.get_ptr_of(val)); } /** * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and * [`TxIn::witness`], each with their lengths included, required to satisfy the output's * script. */ get_satisfaction_weight() { const ret = bindings.Input_get_satisfaction_weight(this.ptr); return ret; } /** * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and * [`TxIn::witness`], each with their lengths included, required to satisfy the output's * script. */ set_satisfaction_weight(val) { bindings.Input_set_satisfaction_weight(this.ptr, val); } /** * Constructs a new Input given each field */ static constructor_new(outpoint_arg, previous_utxo_arg, satisfaction_weight_arg) { const ret = bindings.Input_new(CommonBase.get_ptr_of(outpoint_arg), CommonBase.get_ptr_of(previous_utxo_arg), satisfaction_weight_arg); const ret_hu_conv = new Input(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.Input_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the Input */ clone() { const ret = bindings.Input_clone(this.ptr); const ret_hu_conv = new Input(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the Input. */ hash() { const ret = bindings.Input_hash(this.ptr); return ret; } /** * Checks if two Inputs 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.Input_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } } //# sourceMappingURL=Input.mjs.map