/** * Chain-derived security policy for LIT Actions. * * Replaces the previous attacker-supplied `auth.mode === "prod" | "dev"` * toggle (see audit finding C-1). Policy is derived from the `chain` string * the caller passes, after running it through `validateChain` — anything * outside the known chain set is rejected up front. * * Because every signed EIP-712 payload produced downstream binds the * chainId via OZ EIP712Upgradeable (block.chainid at verify time), an * attacker who lies about `chain` to soften the policy can only obtain a * signature valid under the chain they claimed — which is useless against * any other chain's contracts. Chain binding is therefore sufficient to * make per-chain policy an authoritative switch. */ import { BitcoinNetwork, EVMChain } from "../constants"; export interface ChainPolicy { chain: EVMChain; chainId: number; bitcoinNetwork: BitcoinNetwork; /** * When true, the caller-supplied Bitcoin provider URL is accepted without * looking it up in any allowlist / registry. Only hardhat (regtest) sets * this — the local Bitcoin daemon URL is never fixed. */ allowArbitraryBitcoinProvider: boolean; /** * When true, the caller-supplied EVM RPC URL is accepted without * matching APPROVED_EVM_RPC_DOMAINS. Only hardhat sets this — we * want to allow `http://localhost:8545` during local tests. */ allowArbitraryEvmRpc: boolean; /** * When true, the security-critical contract addresses are taken from the * generated pinned map (constants/chunks/deployment-addresses.ts) and any * caller-supplied values are IGNORED — a contradicting supplied value is * rejected loudly (F1 remediation). sepolia + ethereum set this; hardhat * does not, because local deployments are freshly generated per run and * carry no real funds, so the caller-supplied addresses are used as before. * * This is the ONLY switch that decides "real chain" for address pinning, and * — like allowArbitraryEvmRpc — it is bound to the signed `chain` string, not * to any mutable server env. A caller who lies about `chain` to soften the * policy only obtains a signature valid on the claimed chain, useless * elsewhere (EIP-712 binds block.chainid at verify time). */ pinContractAddresses: boolean; /** * When true, a validator may run the price oracle in single-provider plaintext * mode (one un-encrypted key) instead of the locked 3-of-3 encrypted set. Only * hardhat sets this — it lets the local mega test run with the one key we hold. * sepolia/mainnet keep it false, so a requested dev price flag is REJECTED there; * and because a price is signed against this chain's EIP-712 domain, a hardhat- * signed single-provider price is unusable on any other chain anyway. */ allowDevSinglePriceProvider: boolean; /** * Confirmations a UTXO needs before it counts toward "confirmed vault * balance" (regtest/testnet=1, mainnet=6). This is the single definition of * confirmed balance used by EVERY balance-reading flow — deposit * confirmation, mint, address-balance, and the extend/liquidation/payment * collateral checks — so all validators agree on what a vault holds. * NEVER use this to gate UTXO spends; that is `minBitcoinSpendConfirmations`. */ minBitcoinBalanceConfirmations: number; /** * Confirmations a UTXO needs before the protocol may SPEND it * (regtest/testnet=1, mainnet=6). Reorg protection on outgoing transactions * — used by the btc-withdrawal spend gate and as the stale-spend recovery * floor. Must never be looser than the balance threshold. */ minBitcoinSpendConfirmations: number; /** * Minimum number of registered Bitcoin providers required before any * balance-consensus read may proceed (fail-closed below the floor — see * tasks/security/btc-lit-actions-remediation-plan-2026-07-15.md P1/#1). * hardhat: 1 (single local daemon is the legitimate dev baseline). * sepolia: 1 (single faucet provider by design — the consensus floor is a * mainnet guarantee; multi-provider paths are covered by unit tests). * ethereum: 2 (registry holds Validation Cloud + Blockstream Enterprise * after the 2026-09 Maestro retirement; raise to 3 once a third independent * operator is registered). */ minConsensusProviders: number; } /** * Resolve the security policy for a chain string. Throws on unknown chains. */ export declare function getChainPolicy(chain: string): ChainPolicy; /** * Validate an EVM RPC URL under the given policy. * * hardhat → no-op. * sepolia / ethereum → hostname must equal or end with an approved domain * from APPROVED_EVM_RPC_DOMAINS. The `endsWith(".")` rule already * covers subdomains like `sepolia.drpc.org` / `eth-mainnet.g.alchemy.com` * would match `drpc.org` / an `alchemy.com` entry without extra config. * * Throws on mismatch so the caller doesn't accidentally fall through to an * attacker-controlled RPC. */ export declare function validateEvmRpcForPolicy(policy: ChainPolicy, rpcUrl: string): void; //# sourceMappingURL=chain-policy.d.ts.map