/** * Multi-provider Bitcoin evidence for the stale-spend recovery attestation * (2026-09-22, P2 remediation). * * `stale-spend-recovery-validator` signs a `StaleSpendRecovery` attestation * that unlocks `BTCSpendAuthorizer.cancelStaleSpendWithProof(...)`, and that * entrypoint does NO Bitcoin verification of its own — it deletes an * `AuthorizedSpend` on the validator's word alone, and anyone may submit the * attestation. Every fact behind that signature therefore has to be true: * that the invalidator transaction exists, that it is buried deep enough to * survive a reorg, that it really consumes the reserved outpoint, and what * its input/output values are (the values are what tell "the funds came back * to the vault" apart from "the funds left to an attacker"). * * Before this module all four facts came from `providerConfigs[0]` — ONE * Bitcoin provider. A single compromised or MITM'd provider could invent a * confirmed transaction that spends the reserved outpoint back to the vault, * harvest an attestation, and have a live reservation cancelled while the * real, borrower-signed spend was still perfectly broadcastable. The sibling * spend paths (`btc-transaction-signer`, `btc-utxo-invalidator`) already refuse * to act on one provider's word — they run `confirmedUtxoConsensus` under * `policy.minConsensusProviders` — and this closes the same hole on the * recovery path. * * Why this is not `VaultBalanceConsensus.confirmedUtxoConsensus`: that helper * cross-checks an ADDRESS's UNSPENT outpoint set. The recovery evidence is * transaction-level (a tx that by definition SPENDS the outpoint, plus its vin * prevout values), so there is nothing in the UTXO-set helper to reuse. The * semantics are deliberately copied rather than invented: fail-closed on any * provider failure, throw (never demote, never average) on any disagreement, * and the same depth-skew tolerance. * * Split into a network half (`fetchRecoveryTxEvidence`) and a pure half * (`assertRecoveryEvidenceConsensus`) so the decision that gates the signature * is unit-testable without a Bitcoin node — the same shape as * `invalidator-classification.ts`, which this module feeds. */ import type { BitcoinProviderConfig } from "../../constants"; /** One input of the invalidator tx, with the value of the output it spends. */ export interface RecoveryTxInput { /** Lowercased txid of the transaction whose output this input spends. */ txid: string; vout: number; /** Value of the consumed output, in sats. */ value: bigint; } /** One output of the invalidator tx. */ export interface RecoveryTxOutput { /** Lowercased scriptpubkey_address; empty string when the provider omitted it. */ addressLc: string; value: bigint; } /** The complete Bitcoin evidence one provider reports about the invalidator tx. */ export interface RecoveryTxEvidence { confirmations: number; vin: RecoveryTxInput[]; vout: RecoveryTxOutput[]; } /** A single provider's reading, carrying the name used in every error message. */ export interface RecoveryEvidenceReading { providerName: string; evidence: RecoveryTxEvidence; } /** * Read the full invalidator-tx evidence from ONE provider. * * Confirmations come from `BitcoinDataProvider.getTransaction` (the same read * the validator always used); vin/vout come from the raw `/tx/` body, * because the typed helper does not expose vin. `prevout` is present on * Esplora/mempool.space but stripped by some indexers (the regtest faucet), so * a missing one is backfilled with a per-input lookup on the source tx — * one extra fetch per input, same value, no weakening of the check. * * Every failure throws: a provider that cannot answer must not be silently * dropped from the quorum, or an attacker who can break one endpoint chooses * how many providers have to agree. */ export declare function fetchRecoveryTxEvidence(providerConfig: BitcoinProviderConfig, invalidatorTxid: string, timeoutMs: number): Promise; /** * Agree — or refuse. Returns the single evidence set the attestation may be * built on, or throws. * * Pure: no network, no clock, no Lit runtime, so the exact rule that gates a * recovery signature is directly testable. * * Enforced, in order: * 1. Below `minConsensusProviders` readings → THROW. On a chain whose policy * demands cross-checking (mainnet: 2), one provider's word must never back * a signature that deletes an on-chain reservation. This is the same * fail-closed floor `fetchAllDecryptedProviderConfigs` and * `confirmedUtxoConsensus` apply. * 2. Any provider reporting fewer than `minConfirmations` → THROW. The depth * gate is unanimous, not majority: a transaction one provider still sees * as shallow is one this attestation must not be signed over, and waiting * a block costs nothing (the on-chain MAX_ATTESTATION_AGE is an hour). * 3. Depth spread beyond CONFIRMATION_SKEW_TOLERANCE → THROW. Inside the * tolerance the providers merely saw different tips. * 4. Any reading with an input whose txid is not 64 lowercase hex, or whose * vout is not a non-negative safe integer → THROW. `inputValue` and the * consumed-outpoint check are computed from the primary's inputs, so a * malformed one is refused rather than reasoned over. * 5. Any disagreement on the input set (outpoints AND their values) or the * output set (addresses AND values) → THROW, compared field by field, never * by rendered string. These are exactly the facts * `classifyInvalidatorTransaction` reasons over: a provider that can move * a single value can flip "funds returned to the vault" into a signed * release of a reservation whose funds actually left. * * Values from a confirmed transaction are immutable, so — unlike an address's * UTXO set, where a just-broadcast spend legitimately races — there is no * benign reason for two providers to differ here. Strict equality is correct. */ export declare function assertRecoveryEvidenceConsensus(readings: RecoveryEvidenceReading[], minConfirmations: number, minConsensusProviders: number): RecoveryTxEvidence; //# sourceMappingURL=recovery-evidence.d.ts.map