import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm'; /** * Parameters for building an unsigned Payout PSBT * * Payout is used in the challenge path after Assert, when the claimer proves validity. * Input 1 references the Assert transaction. */ export interface PayoutParams { /** * Vault core (tx-graph) version the vault was registered under — the * vault's stamped on-chain `vaultCoreVersion`. Selects which graph's * payout connector scripts are derived. */ vaultCoreVersion: number; /** * Payout transaction hex (unsigned) * This is the transaction that needs to be signed by the depositor */ payoutTxHex: string; /** * Assert transaction hex * Payout input 1 references Assert output 0 */ assertTxHex: string; /** * Peg-in transaction hex * This transaction created the vault output that we're spending */ peginTxHex: string; /** * Depositor's BTC public key (x-only, 64-char hex without 0x prefix) */ depositorBtcPubkey: string; /** * Vault provider's BTC public key (x-only, 64-char hex) */ vaultProviderBtcPubkey: string; /** * Vault keeper BTC public keys (x-only, 64-char hex) */ vaultKeeperBtcPubkeys: string[]; /** * Universal challenger BTC public keys (x-only, 64-char hex) */ universalChallengerBtcPubkeys: string[]; /** * CSV timelock in blocks for the PegIn output (btc-vault `timelock_pegin`); * payout input 0's sequence. */ timelockPegin: number; /** * CSV timelock in blocks on the Assert:0 payout leaf (btc-vault * `timelock_assert`); payout input 1's sequence. */ timelockAssert: number; /** * Bitcoin network */ network: Network; /** * Claimer's x-only BTC public key (64-char hex, no prefix). Drives role * inference (VP / depositor-as-claimer / VK-claimer) inside `buildPayoutPsbt`. */ claimerBtcPubkey: string; /** * On-chain registered depositor payout scriptPubKey (hex, 0x optional). * Expected outs[0].script for VP- and depositor-claimer roles; unused for * VK-claimer (its outs[0].script is derived from `claimerBtcPubkey`). */ registeredPayoutScriptPubKey: string; /** * VP commission in basis points (`BTCVaultRegistry.vaultProviderCommissionBps`). * Caps the VP-claimer outs[1].value. The protocol minimum is enforced * upstream; here only `0 <= bps < 10_000` is checked, for safe cap math. */ commissionBps: number; /** * Tx-graph fee rate (sat/vB) the graph was built with — the version-locked * `offchainParams.feeRate` at the vault's stamped `offchainParamsVersion`, * NOT a live read. Anchors both ends of the fee band. */ protocolFeeRate: bigint; /** * Security council member x-only public keys (hex) from the locked offchain * params version — `getOffchainParamsByVersion(...).securityCouncilKeys`. * The council occupies the last leaf of the Assert:0 taptree * (btc-vault `crates/vault/src/connectors/assert_payout_nopayout_council.rs`), * so the keys are needed to rebuild input 1's payout leaf, and the count * feeds the fee-band domain. */ councilMembers: string[]; /** * M-of-N council quorum from the locked offchain params version — * `getOffchainParamsByVersion(...).councilQuorum`. Shapes the council leaf's * multisig script, and with it the Assert:0 taptree root. */ councilQuorum: number; /** * RFC-006. Expected `outs[0].script` per vault-keeper claimer, keyed by * lowercased x-only **operation** pubkey (no `0x`), resolved from * `ApplicationRegistry.getPayoutScriptAtEpoch` at the vault's frozen * `appKeeperKeyEpoch`. * * Every VK claimer must be present: a claimer missing from the map is an * error rather than a cue to derive BIP-86, because a gap means resolution * was incomplete and we do not know what that keeper registered. * * Each entry accepts either that registered script or the BIP-86 default of * the same bonded key, so graphs built before btc-vault#2440 remain signable * — see {@link acceptedPayoutScriptHexes} for why that is required and when * it can be dropped. */ vkClaimerPayoutScriptPubKeys: Readonly>; /** * RFC-006. Expected `outs[1].script` for the VP-claimer commission output, * from `BTCVaultRegistry.getPayoutScriptAtEpoch` at the vault's frozen * `vpKeyEpoch`. The BIP-86 default of the bonded VP key is accepted alongside * it — see {@link acceptedPayoutScriptHexes}. */ vpCommissionScriptPubKey: string; } /** * Result of building an unsigned payout PSBT */ export interface PayoutPsbtResult { /** * Unsigned PSBT hex ready for signing */ psbtHex: string; } /** * Build unsigned Payout PSBT for depositor to sign. * * Payout is used in the **challenge path** when the claimer proves validity: * 1. Vault provider submits Claim transaction * 2. Challenge is raised during challenge period * 3. Claimer submits Assert transaction to prove validity * 4. Payout can be executed (references Assert tx) * * Payout transactions have the following structure: * - Input 0: from PeginTx output0 (signed by depositor) * - Input 1: from Assert output0 (NOT signed by depositor) * * Both inputs carry their taproot script-path leaf. Input 1's is not signed * here — it is what a hardware signer reads to display the payout terms. * * @param params - Payout parameters * @returns Unsigned PSBT ready for depositor to sign * * @throws If payout transaction does not have exactly 2 inputs * @throws If input 0 does not spend PegIn:0 (vault UTXO) * @throws If input 1 does not spend Assert:0 (proof output) * @throws If previous output is not found for either input * @throws If sum of output values exceeds sum of input values (invalid tx) * @throws If the implicit fee (inputs − outputs) is outside the fee band — * below the floor or above the fee-band ceiling (see * {@link assertPayoutFeeInBand}) * @throws If `protocolFeeRate`, a participant count, or the council size is * outside the accepted input domain (see {@link assertPayoutFeeBandDomain}) * @throws If a non-anchor scriptPubKey length is outside `[1, * {@link MAX_PAYOUT_SCRIPT_LEN}]` * @throws If `claimerBtcPubkey` is not VP, depositor, or a registered VK * @throws If payout output count, outs[0] script, outs[last] anchor value, or * (VP-claimer) outs[1] commission cap do not match the protocol layout * @throws If `commissionBps` is not a non-negative integer below 10_000 * @throws If the locally rebuilt Assert:0 payout leaf does not bind to the * Assert output input 1 spends */ export declare function buildPayoutPsbt(params: PayoutParams): Promise; /** * Extract Schnorr signature from signed payout PSBT. * * This function supports two cases: * 1. Non-finalized PSBT: Extracts from tapScriptSig field * 2. Finalized PSBT: Extracts from witness data * * The signature is returned as a 64-byte hex string (128 hex characters). * Payout signatures must use implicit Taproot SIGHASH_DEFAULT, which is * encoded by omitting the sighash byte. * * @param signedPsbtHex - Signed PSBT hex * @param depositorPubkey - Depositor's public key (x-only, 64-char hex) * @param inputIndex - Input index to extract signature from (default: 0) * @returns 64-byte Schnorr signature (128 hex characters, no sighash flag) * * @throws If no signature is found in the PSBT * @throws If the signature has an unexpected length */ export declare function extractPayoutSignature(signedPsbtHex: string, depositorPubkey: string, inputIndex?: number): string; //# sourceMappingURL=payout.d.ts.map