"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashTransaction = exports.ZcashTransaction = exports.Transaction = void 0;
const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
/**
 * Transaction wrapper (Bitcoin-like networks)
 *
 * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
 */
class Transaction {
    _wasm;
    constructor(_wasm) {
        this._wasm = _wasm;
    }
    /**
     * Create an empty transaction (version 1, locktime 0)
     */
    static create() {
        return new Transaction(wasm_utxo_js_1.WasmTransaction.create());
    }
    static fromBytes(bytes) {
        return new Transaction(wasm_utxo_js_1.WasmTransaction.from_bytes(bytes));
    }
    /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
    static fromWasm(wasm) {
        return new Transaction(wasm);
    }
    /**
     * Add an input to the transaction
     * @param txid - Previous transaction ID (hex string)
     * @param vout - Output index being spent
     * @param sequence - Optional sequence number (default: 0xFFFFFFFF)
     * @returns The index of the newly added input
     */
    addInputAtIndex(index, txid, vout, sequence) {
        return this._wasm.add_input_at_index(index, txid, vout, sequence);
    }
    addInput(txid, vout, sequence) {
        return this._wasm.add_input(txid, vout, sequence);
    }
    addOutputAtIndex(index, script, value) {
        return this._wasm.add_output_at_index(index, script, value);
    }
    addOutput(script, value) {
        return this._wasm.add_output(script, value);
    }
    toBytes() {
        return this._wasm.to_bytes();
    }
    /**
     * Get the transaction ID (txid)
     *
     * The txid is the double SHA256 of the transaction bytes (excluding witness
     * data for segwit transactions), displayed in reverse byte order as is standard.
     *
     * @returns The transaction ID as a hex string
     */
    getId() {
        return this._wasm.get_txid();
    }
    /**
     * Get the virtual size of the transaction
     *
     * Virtual size accounts for the segwit discount on witness data.
     *
     * @returns The virtual size in virtual bytes (vbytes)
     */
    getVSize() {
        return this._wasm.get_vsize();
    }
    inputCount() {
        return this._wasm.input_count();
    }
    outputCount() {
        return this._wasm.output_count();
    }
    version() {
        return this._wasm.version();
    }
    lockTime() {
        return this._wasm.lock_time();
    }
    getInputs() {
        return this._wasm.get_inputs();
    }
    getOutputs() {
        return this._wasm.get_outputs();
    }
    getOutputsWithAddress(coin) {
        return this._wasm.get_outputs_with_address(coin);
    }
    /** @internal */
    get wasm() {
        return this._wasm;
    }
}
exports.Transaction = Transaction;
/**
 * Zcash Transaction wrapper
 *
 * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
 */
class ZcashTransaction {
    _wasm;
    constructor(_wasm) {
        this._wasm = _wasm;
    }
    static fromBytes(bytes) {
        return new ZcashTransaction(wasm_utxo_js_1.WasmZcashTransaction.from_bytes(bytes));
    }
    /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
    static fromWasm(wasm) {
        return new ZcashTransaction(wasm);
    }
    toBytes() {
        return this._wasm.to_bytes();
    }
    /**
     * Get the transaction ID (txid)
     *
     * The txid is the double SHA256 of the full Zcash transaction bytes,
     * displayed in reverse byte order as is standard.
     *
     * @returns The transaction ID as a hex string
     */
    getId() {
        return this._wasm.get_txid();
    }
    inputCount() {
        return this._wasm.input_count();
    }
    outputCount() {
        return this._wasm.output_count();
    }
    version() {
        return this._wasm.version();
    }
    lockTime() {
        return this._wasm.lock_time();
    }
    getInputs() {
        return this._wasm.get_inputs();
    }
    getOutputs() {
        return this._wasm.get_outputs();
    }
    getOutputsWithAddress(coin) {
        return this._wasm.get_outputs_with_address(coin);
    }
    /** @internal */
    get wasm() {
        return this._wasm;
    }
}
exports.ZcashTransaction = ZcashTransaction;
/**
 * Dash Transaction wrapper (supports EVO special transactions)
 *
 * Round-trip only: bytes -> parse -> bytes.
 */
class DashTransaction {
    _wasm;
    constructor(_wasm) {
        this._wasm = _wasm;
    }
    static fromBytes(bytes) {
        return new DashTransaction(wasm_utxo_js_1.WasmDashTransaction.from_bytes(bytes));
    }
    /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
    static fromWasm(wasm) {
        return new DashTransaction(wasm);
    }
    toBytes() {
        return this._wasm.to_bytes();
    }
    /**
     * Get the transaction ID (txid)
     *
     * The txid is the double SHA256 of the full Dash transaction bytes,
     * displayed in reverse byte order as is standard.
     *
     * @returns The transaction ID as a hex string
     */
    getId() {
        return this._wasm.get_txid();
    }
    inputCount() {
        return this._wasm.input_count();
    }
    outputCount() {
        return this._wasm.output_count();
    }
    version() {
        return this._wasm.version();
    }
    lockTime() {
        return this._wasm.lock_time();
    }
    getInputs() {
        return this._wasm.get_inputs();
    }
    getOutputs() {
        return this._wasm.get_outputs();
    }
    getOutputsWithAddress(coin) {
        return this._wasm.get_outputs_with_address(coin);
    }
    /** @internal */
    get wasm() {
        return this._wasm;
    }
}
exports.DashTransaction = DashTransaction;
