import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm'; /** * Parameters for building an unfunded Pre-PegIn PSBT */ export interface PrePeginParams { /** * Vault core (tx-graph) version to build. Fresh deposits use the contract's * `ProtocolParams.activeVaultCoreVersion()`; resumed vaults use their * stamped on-chain `vaultCoreVersion`. The WASM facade fails closed on * versions it wasn't compiled with. */ vaultCoreVersion: number; /** Depositor's BTC public key (x-only, 64-char hex without 0x prefix) */ depositorPubkey: string; /** Vault provider's BTC public key (x-only, 64-char hex) */ vaultProviderPubkey: string; /** Array of vault keeper BTC public keys (x-only, 64-char hex) */ vaultKeeperPubkeys: string[]; /** Array of universal challenger BTC public keys (x-only, 64-char hex) */ universalChallengerPubkeys: string[]; /** SHA256 hash commitment(s) (64 hex chars = 32 bytes each) */ hashlocks: readonly string[]; /** CSV timelock in blocks for the HTLC refund path */ timelockRefund: number; /** Amounts to peg in (satoshis), one per deposit */ pegInAmounts: readonly bigint[]; /** TX-graph fee rate in sat/vB from contract offchain params; sizes the depositor claim value */ feeRate: bigint; /** Minimum PegIn fee rate in sat/vB from contract offchain params; sizes the PegIn tx fee */ minPeginFeeRate: bigint; /** Number of local challengers (from contract params) */ numLocalChallengers: number; /** M in M-of-N council multisig (from contract params) */ councilQuorum: number; /** N in M-of-N council multisig (from contract params) */ councilSize: number; /** Bitcoin network */ network: Network; /** * Optional 32-byte `SHA256(auth_anchor)` commitment (64-char hex, no * `0x` prefix). If provided, the Pre-PegIn tx will include an * `OP_RETURN ` output at vout = * `hashlocks.length`, binding the depositor's bearer-token * `auth_anchor` preimage to this Pre-PegIn. */ authAnchorHash?: string; } /** * Result of building an unfunded Pre-PegIn transaction */ export interface PrePeginPsbtResult { /** * Unfunded transaction hex (no inputs, HTLC outputs + optional * auth-anchor OP_RETURN + CPFP anchor). * * The caller is responsible for: * - Selecting UTXOs covering totalOutputValue + network fees * - Funding the transaction (add inputs and change output) * - Calling buildPeginTxFromFundedPrePegin() with the funded tx hex */ psbtHex: string; /** Sum of all unfunded outputs — use this for UTXO selection */ totalOutputValue: bigint; /** * HTLC output values in satoshis, one per deposit. Each includes * peginAmount + depositorClaimValue + p2aAnchorValue + minPeginFee (the * anchor term is 0 for graph versions without a P2A anchor, 240 for v2/v3). */ htlcValues: readonly bigint[]; /** HTLC output scriptPubKeys (hex encoded), one per deposit */ htlcScriptPubKeys: readonly string[]; /** HTLC Taproot addresses, one per deposit */ htlcAddresses: readonly string[]; /** Pegin amounts in satoshis, one per deposit */ peginAmounts: readonly bigint[]; /** Depositor claim value computed by WASM from contract parameters */ depositorClaimValue: bigint; /** * Vout index of the auth-anchor `OP_RETURN` output if one was * included (i.e. `authAnchorHash` was provided), or `null` if not. * Always equals `htlcValues.length` when present. */ authAnchorVout: number | null; /** * Minimum PegIn fee (sats), independently computed and asserted against * `htlcValues`' implied reserve by {@link assertWasmPeginSizing}. Reuse * this instead of recomputing — it is already the cross-checked value. */ minPeginFee: bigint; } /** * Parameters for building the PegIn transaction from a funded Pre-PegIn tx */ export interface BuildPeginTxParams { /** Same PrePeginParams used to create the Pre-PegIn transaction */ prePeginParams: PrePeginParams; /** CSV timelock in blocks for the PegIn vault output */ timelockPegin: number; /** Hex-encoded funded Pre-PegIn transaction */ fundedPrePeginTxHex: string; /** Index of the HTLC output to spend */ htlcVout: number; } /** * Result of building the PegIn transaction */ export interface PeginTxResult { /** * PegIn transaction hex. 1 input spending the HTLC; outputs are * version-shaped: v1 = vault + depositor claim, v2/v3 = vault + depositor * claim + P2A anchor at vout 2 (nVersion 3 / TRUC). */ txHex: string; /** PegIn transaction ID */ txid: string; /** Vault output scriptPubKey (hex encoded) */ vaultScriptPubKey: string; /** Vault output value in satoshis */ vaultValue: bigint; } /** * Build unfunded Pre-PegIn transaction using WASM. * * Creates a Bitcoin transaction template with no inputs, an HTLC output, and a * CPFP anchor output. The HTLC value is computed internally from the contract * parameters — the caller does not need to compute depositorClaimValue separately. * * @param params - Pre-PegIn parameters * @returns Unfunded Pre-PegIn transaction details with HTLC output information * @throws If WASM initialization fails or parameters are invalid */ export declare function buildPrePeginPsbt(params: PrePeginParams): Promise; /** * Validate and normalize an `authAnchorHash` hex string before passing * it to the WASM boundary. WASM expects exactly 64 lowercase hex chars. */ export declare function normalizeAuthAnchorHash(value: string | undefined): string | undefined; /** * Build the PegIn transaction from a funded Pre-PegIn transaction. * * The PegIn transaction spends the Pre-PegIn HTLC output at htlcVout via the * hashlock + all-party script (leaf 0). * * @param params - Build parameters including Pre-PegIn params and funded tx hex * @returns PegIn transaction details * @throws If WASM initialization fails or parameters are invalid */ export declare function buildPeginTxFromFundedPrePegin(params: BuildPeginTxParams): Promise; //# sourceMappingURL=pegin.d.ts.map