import type { BitcoinProviderConfig } from "../constants"; /** Minimal balance-reading surface — lets tests inject a stub without a network. */ export interface BalanceReader { getBalance(address: string): Promise; } /** * Factory for a balance reader from a provider config (so per-provider `auth` — * Maestro api-key / Blockstream Enterprise OAuth — is applied to every * cross-check request). Defaults to a real `BitcoinDataProvider`. */ export type BalanceReaderFactory = (config: BitcoinProviderConfig) => BalanceReader; /** * Multi-provider Bitcoin balance consensus (audit C-1/C-2 follow-up). * * Cross-checks the confirmed balance of `vaultAddress` across every registered * Bitcoin provider and throws on ANY disagreement, so a single compromised / * MITM'd provider cannot influence a value the PKP is about to sign over * (forged collateral → unbacked mint; forged ~0 balance → liquidate a healthy * position). Strict equality is intentional and fail-closed: the providers must * agree on the exact confirmed balance — identical semantics to the block this * was extracted from in `btc-withdrawal.ts`. * * Consensus floor (remediation P1/#1): `minConsensusProviders` comes from * `getChainPolicy(chain)` — NEVER from jsParams. Below the floor this THROWS * (fail-closed) instead of silently skipping: on a chain whose policy demands * cross-checking, a single provider's word must never back a signed value. * With a floor of 1 (hardhat/sepolia single-provider baseline) a 0/1-provider * list still skips the cross-check exactly as before. * * @param vaultAddress Bitcoin address whose confirmed balance is being signed over. * @param providerConfigs All registered providers (e.g. from `resolveAllBitcoinProviders`). * @param minConsensusProviders Policy floor (`policy.minConsensusProviders`). * @param timeoutMs Optional per-provider request timeout (matches the caller's data provider). * @param makeReader Optional balance-reader factory (test injection); defaults to `BitcoinDataProvider`. * @returns the agreed balance (sats) when consensus ran, or `null` when skipped (single-provider floor-1 chains). */ export declare function assertBitcoinBalanceConsensus(vaultAddress: string, providerConfigs: BitcoinProviderConfig[], minConsensusProviders: number, timeoutMs?: number, makeReader?: BalanceReaderFactory): Promise; /** * Read the confirmed balance of `vaultAddress` from EVERY provider concurrently * and return the agreed value. * * Queries all providers in parallel (each call is independently AbortController- * capped at `timeoutMs` inside `BitcoinDataProvider`, so wall-time ≈ the slowest * single call, not the sum — this is what keeps multi-provider consensus inside * the ~30s Lit Action budget). Fail-closed: * - any provider request that rejects → throw, naming every failed provider; * - with ≥2 providers, any balance that differs from the primary → throw, * naming every mismatch (same C-1/C-2 guarantee as the sequential version). * * Returns the primary provider's balance. Requires ≥1 provider AND at least * the policy's `minConsensusProviders` (P1/#1 — fail-closed below the floor). * Used directly by the balance/payment validators (which need the value even * with one provider) and indirectly by {@link assertBitcoinBalanceConsensus}. */ export declare function readConsensusBalance(vaultAddress: string, providerConfigs: BitcoinProviderConfig[], minConsensusProviders: number, timeoutMs?: number, makeReader?: BalanceReaderFactory): Promise; //# sourceMappingURL=bitcoin-balance-consensus.module.d.ts.map