"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BitGoPsbt = void 0;
exports.outputScript = outputScript;
exports.address = address;
const wasm_utxo_1 = require("./wasm/wasm_utxo");
/**
 * Create the output script for a given wallet keys and chain and index
 */
function outputScript(keys, chain, index, network) {
    return wasm_utxo_1.FixedScriptWalletNamespace.output_script(keys, chain, index, network);
}
/**
 * Create the address for a given wallet keys and chain and index and network.
 * Wrapper for outputScript that also encodes the script to an address.
 * @param keys - The wallet keys to use.
 * @param chain - The chain to use.
 * @param index - The index to use.
 * @param network - The network to use.
 * @param addressFormat - The address format to use.
 *   Only relevant for Bitcoin Cash and eCash networks, where:
 *   - "default" means base58check,
 *   - "cashaddr" means cashaddr.
 */
function address(keys, chain, index, network, addressFormat) {
    return wasm_utxo_1.FixedScriptWalletNamespace.address(keys, chain, index, network, addressFormat);
}
const wasm_utxo_2 = require("./wasm/wasm_utxo");
class BitGoPsbt {
    wasm;
    constructor(wasm) {
        this.wasm = wasm;
    }
    /**
     * Deserialize a PSBT from bytes
     * @param bytes - The PSBT bytes
     * @param network - The network to use for deserialization (either utxolib name like "bitcoin" or coin name like "btc")
     * @returns A BitGoPsbt instance
     */
    static fromBytes(bytes, network) {
        const wasm = wasm_utxo_2.BitGoPsbt.from_bytes(bytes, network);
        return new BitGoPsbt(wasm);
    }
    /**
     * Parse transaction with wallet keys to identify wallet inputs/outputs
     * @param walletKeys - The wallet keys to use for identification
     * @param replayProtection - Scripts that are allowed as inputs without wallet validation
     * @returns Parsed transaction information
     */
    parseTransactionWithWalletKeys(walletKeys, replayProtection) {
        return this.wasm.parse_transaction_with_wallet_keys(walletKeys, replayProtection);
    }
    /**
     * Parse outputs with wallet keys to identify which outputs belong to a wallet
     * with the given wallet keys.
     *
     * This is useful in cases where we want to identify outputs that belong to a different
     * wallet than the inputs.
     *
     * @param walletKeys - The wallet keys to use for identification
     * @returns Array of parsed outputs
     * @note This method does NOT validate wallet inputs. It only parses outputs.
     */
    parseOutputsWithWalletKeys(walletKeys) {
        return this.wasm.parse_outputs_with_wallet_keys(walletKeys);
    }
}
exports.BitGoPsbt = BitGoPsbt;
