UNPKG

lightningdevkit

Version:
161 lines 5.66 kB
import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs'; import { ChannelId } from '../structs/ChannelId.mjs'; import { Result_TxAddInputDecodeErrorZ } from '../structs/Result_TxAddInputDecodeErrorZ.mjs'; import { TransactionU16LenLimited } from '../structs/TransactionU16LenLimited.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * A [`tx_add_input`] message for adding an input during interactive transaction construction * * [`tx_add_input`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-tx_add_input-message */ export class TxAddInput extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.TxAddInput_free); } /** * The channel ID */ get_channel_id() { const ret = bindings.TxAddInput_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.TxAddInput_set_channel_id(this.ptr, CommonBase.get_ptr_of(val)); } /** * A randomly chosen unique identifier for this input, which is even for initiators and odd for * non-initiators. */ get_serial_id() { const ret = bindings.TxAddInput_get_serial_id(this.ptr); return ret; } /** * A randomly chosen unique identifier for this input, which is even for initiators and odd for * non-initiators. */ set_serial_id(val) { bindings.TxAddInput_set_serial_id(this.ptr, val); } /** * Serialized transaction that contains the output this input spends to verify that it is non * malleable. */ get_prevtx() { const ret = bindings.TxAddInput_get_prevtx(this.ptr); const ret_hu_conv = new TransactionU16LenLimited(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Serialized transaction that contains the output this input spends to verify that it is non * malleable. */ set_prevtx(val) { bindings.TxAddInput_set_prevtx(this.ptr, CommonBase.get_ptr_of(val)); } /** * The index of the output being spent */ get_prevtx_out() { const ret = bindings.TxAddInput_get_prevtx_out(this.ptr); return ret; } /** * The index of the output being spent */ set_prevtx_out(val) { bindings.TxAddInput_set_prevtx_out(this.ptr, val); } /** * The sequence number of this input */ get_sequence() { const ret = bindings.TxAddInput_get_sequence(this.ptr); return ret; } /** * The sequence number of this input */ set_sequence(val) { bindings.TxAddInput_set_sequence(this.ptr, val); } /** * The ID of the previous funding transaction, when it is being added as an input during splicing */ get_shared_input_txid() { const ret = bindings.TxAddInput_get_shared_input_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 ID of the previous funding transaction, when it is being added as an input during splicing */ set_shared_input_txid(val) { bindings.TxAddInput_set_shared_input_txid(this.ptr, CommonBase.get_ptr_of(val)); } /** * Constructs a new TxAddInput given each field */ static constructor_new(channel_id_arg, serial_id_arg, prevtx_arg, prevtx_out_arg, sequence_arg, shared_input_txid_arg) { const ret = bindings.TxAddInput_new(CommonBase.get_ptr_of(channel_id_arg), serial_id_arg, CommonBase.get_ptr_of(prevtx_arg), prevtx_out_arg, sequence_arg, CommonBase.get_ptr_of(shared_input_txid_arg)); const ret_hu_conv = new TxAddInput(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.TxAddInput_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the TxAddInput */ clone() { const ret = bindings.TxAddInput_clone(this.ptr); const ret_hu_conv = new TxAddInput(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the TxAddInput. */ hash() { const ret = bindings.TxAddInput_hash(this.ptr); return ret; } /** * Checks if two TxAddInputs 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.TxAddInput_eq(this.ptr, CommonBase.get_ptr_of(b)); CommonBase.add_ref_from(this, b); return ret; } /** * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read */ write() { const ret = bindings.TxAddInput_write(this.ptr); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } /** * Read a TxAddInput from a byte array, created by TxAddInput_write */ static constructor_read(ser) { const ret = bindings.TxAddInput_read(bindings.encodeUint8Array(ser)); const ret_hu_conv = Result_TxAddInputDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } } //# sourceMappingURL=TxAddInput.mjs.map