+ self.txin_defn = """export class TxIn extends CommonBase {
+ /** The witness in this input, in serialized form */
+ public witness: Uint8Array;
+ /** The script_sig in this input */
+ public script_sig: Uint8Array;
+ /** The transaction output's sequence number */
+ public sequence: number;
+ /** The txid this input is spending */
+ public previous_txid: Uint8Array;
+ /** The output index within the spent transaction of the output this input is spending */
+ public previous_vout: number;
+
+ /* @internal */
+ public constructor(_dummy: null, ptr: bigint) {
+ super(ptr, bindings.TxIn_free);
+ this.witness = bindings.decodeUint8Array(bindings.TxIn_get_witness(ptr));
+ this.script_sig = bindings.decodeUint8Array(bindings.TxIn_get_script_sig(ptr));
+ this.sequence = bindings.TxIn_get_sequence(ptr);
+ this.previous_txid = bindings.decodeUint8Array(bindings.TxIn_get_previous_txid(ptr));
+ this.previous_vout = bindings.TxIn_get_previous_vout(ptr);
+ }
+ public static constructor_new(witness: Uint8Array, script_sig: Uint8Array, sequence: number, previous_txid: Uint8Array, previous_vout: number): TxIn {
+ return new TxIn(null, bindings.TxIn_new(bindings.encodeUint8Array(witness), bindings.encodeUint8Array(script_sig), sequence, bindings.encodeUint8Array(previous_txid), previous_vout));
+ }
+}"""
+ self.obj_defined(["TxIn"], "structs")
+
+ self.scalar_defn = """export class BigEndianScalar extends CommonBase {
+ /** The bytes of the scalar value, in big endian */
+ public scalar_bytes: Uint8Array;
+
+ /* @internal */
+ public constructor(_dummy: null, ptr: bigint) {
+ super(ptr, bindings.BigEndianScalar_free);
+ this.scalar_bytes = bindings.decodeUint8Array(bindings.BigEndianScalar_get_bytes(ptr));
+ }
+ public static constructor_new(scalar_bytes: Uint8Array): BigEndianScalar {
+ return new BigEndianScalar(null, bindings.BigEndianScalar_new(bindings.encodeUint8Array(scalar_bytes)));
+ }
+}"""
+ self.obj_defined(["BigEndianScalar"], "structs")
+
+ self.witness_program_defn = """export class WitnessProgram extends CommonBase {
+ /** The witness program bytes themselves */
+ public program: Uint8Array;
+ /** The witness program version */
+ public version: WitnessVersion;
+
+ /* @internal */
+ public constructor(_dummy: null, ptr: bigint) {
+ super(ptr, bindings.WitnessProgram_free);
+ this.program = bindings.decodeUint8Array(bindings.WitnessProgram_get_program(ptr));
+ this.version = new WitnessVersion(bindings.WitnessProgram_get_version(ptr));
+ }
+ public static constructor_new(program: Uint8Array, version: WitnessVersion): WitnessProgram {
+ if (program.length < 2 || program.length > 40)
+ throw new Error("WitnessProgram must be between 2 and 40 bytes long");
+ if (version.getVal() == 0 && program.length != 20 && program.length != 32)
+ throw new Error("WitnessProgram for version 0 must be between either 20 or 30 bytes");
+ return new WitnessProgram(null, bindings.WitnessProgram_new(version.getVal(), bindings.encodeUint8Array(program)));
+ }
+}"""
+ self.obj_defined(["WitnessProgram"], "structs")
+