import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
import { TransactionBase } from "./transactionBase.js";
/**
 * Transaction wrapper (Bitcoin-like networks)
 *
 * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
 */
export class Transaction extends TransactionBase {
    constructor(wasm) {
        super(wasm);
    }
    /**
     * Check if a coin is supported by this transaction class.
     * Bitcoin-like transactions support all coins except Zcash and Dash.
     */
    static supportsCoin(coin) {
        return !ZcashTransaction.supportsCoin(coin) && !DashTransaction.supportsCoin(coin);
    }
    /**
     * Create an empty transaction (version 1, locktime 0)
     */
    static create() {
        return new Transaction(WasmTransaction.create());
    }
    static fromBytes(bytes, coin) {
        if (coin !== undefined) {
            if (ZcashTransaction.supportsCoin(coin))
                return ZcashTransaction.fromBytes(bytes);
            if (DashTransaction.supportsCoin(coin))
                return DashTransaction.fromBytes(bytes);
        }
        return new Transaction(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);
    }
    /**
     * 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();
    }
    /** @internal */
    get wasm() {
        return this._wasm;
    }
}
/**
 * Zcash Transaction wrapper
 *
 * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
 */
export class ZcashTransaction extends TransactionBase {
    constructor(wasm) {
        super(wasm);
    }
    /**
     * Check if a coin is supported by this transaction class.
     * Zcash transactions support Zcash mainnet and testnet.
     */
    static supportsCoin(coin) {
        return coin === "zec" || coin === "tzec";
    }
    static fromBytes(bytes) {
        return new ZcashTransaction(WasmZcashTransaction.from_bytes(bytes));
    }
    /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
    static fromWasm(wasm) {
        return new ZcashTransaction(wasm);
    }
    /** @internal */
    get wasm() {
        return this._wasm;
    }
}
/**
 * Dash Transaction wrapper (supports EVO special transactions)
 *
 * Round-trip only: bytes -> parse -> bytes.
 */
export class DashTransaction extends TransactionBase {
    constructor(wasm) {
        super(wasm);
    }
    /**
     * Check if a coin is supported by this transaction class.
     * Dash transactions support Dash mainnet and testnet.
     */
    static supportsCoin(coin) {
        return coin === "dash" || coin === "tdash";
    }
    static fromBytes(bytes) {
        return new DashTransaction(WasmDashTransaction.from_bytes(bytes));
    }
    /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
    static fromWasm(wasm) {
        return new DashTransaction(wasm);
    }
    /** @internal */
    get wasm() {
        return this._wasm;
    }
}
