/** * UTXO selection utilities for peg-in transactions. * Follows btc-staking-ts methodology with iterative fee calculation. */ /** * Unspent Transaction Output (UTXO) for funding peg-in transactions. */ export interface UTXO { /** * Transaction ID of the UTXO (64-char hex without 0x prefix). */ txid: string; /** * Output index within the transaction. */ vout: number; /** * Value in satoshis. */ value: number; /** * Script public key hex. */ scriptPubKey: string; } export interface UTXOSelectionResult { selectedUTXOs: UTXO[]; totalValue: bigint; fee: bigint; changeAmount: bigint; } /** * Selects UTXOs to fund a peg-in transaction with iterative fee calculation. * * This function implements the btc-staking-ts approach: * 1. Filter UTXOs for script validity (no minimum value filter) * 2. Sort by value (largest first) to minimize number of inputs * 3. Iteratively add UTXOs and recalculate fee until we have enough * * The fee recalculation is critical because: * - Each UTXO added increases transaction size → increases fee * - More fee needed might require another UTXO * - Change output detection affects fee (adds output size if needed) * * @param availableUTXOs - All available UTXOs from wallet * @param peginAmount - Amount to peg in (satoshis) * @param feeRate - Fee rate (sat/vbyte) * @param numOutputs - Number of outputs in the unfunded transaction (HTLC + CPFP anchor, before change) * @returns Selected UTXOs, total value, calculated fee, and change amount * @throws Error if insufficient funds or no valid UTXOs */ export declare function selectUtxosForPegin(availableUTXOs: UTXO[], peginAmount: bigint, feeRate: number, numOutputs: number): UTXOSelectionResult; /** * Checks if change amount is above dust threshold. * * @param changeAmount - Change amount in satoshis * @returns true if change should be added as output, false if it should go to miners */ export declare function shouldAddChangeOutput(changeAmount: bigint): boolean; /** * Gets the dust threshold value. * * @returns Dust threshold in satoshis */ export declare function getDustThreshold(): number; //# sourceMappingURL=selectUtxos.d.ts.map