import { AccountId } from 'caip'; import type { AccountClientInterface, AccountStatus } from '../client'; import type { VaultEncryptionKeyWithMetadata } from '../../cryptography'; import { LibQCStorage } from '../../storage'; import type { PersistedAccount } from '../../state'; import { type Activity, type Asset, type BalanceResult, type GetActivityFilters, type WithdrawalRecord } from '../../types'; import { ChainSpecification } from '../../publicClients'; import type { BitcoinChainApi } from './api'; import type { EmptyVaultResult } from '../../types'; /** * Bitcoin account client implementing AccountClientInterface * * Uses Blockstream Esplora API for balance and transaction history. * Fetches data directly via fetch—no separate client abstraction. * * Instances are created via `LibQC.getAccount()` or `LibQC.createAccount()` for Bitcoin chains. * * @example * ```typescript * const account = await vault.getAccount(accountId); * const balance = await account.getBalance(asset); * ``` */ export declare class BitcoinAccountClient implements AccountClientInterface { private account; private storage; private encryptionKey; private api; private chainSpec; /** * Creates a new BitcoinAccountClient instance * * @param account - Persisted account data * @param storage - Storage implementation for persisting state * @param encryptionKey - Key for decrypting vault state * @param api - Bitcoin chain API for balance and transaction data * @param chainSpec - Chain specification for native asset lookup * * @internal */ constructor(account: PersistedAccount, storage: LibQCStorage, encryptionKey: VaultEncryptionKeyWithMetadata, api: BitcoinChainApi, chainSpec: ChainSpecification); /** * Public getter for the ID of the account * * @returns The account ID */ getId(): AccountId; /** * Gets the BTC balance for the account * * Only native BTC is supported; non-native assets throw AssetEntityNotFoundError. * * This fetches from Blockstream Esplora API: https://github.com/Blockstream/esplora/blob/master/API.md#get-addressaddress * * @param asset - Asset to fetch balance for (must be native BTC) * @returns Balance result with balance, decimals, and symbol. * Decimals come from the asset entity definition (there is no * on-chain decimals query for Bitcoin, unlike EVM ERC-20s). */ getBalance(asset: Asset): Promise; /** * Gets the balances for multiple assets * * @param assets - Assets to fetch balances for * @returns Balance results */ getBalances(assets: Asset[]): Promise; /** * Fetches transactions from the Bitcoin chain API and maps to BitcoinTransactionActivity[] */ private fetchActivities; /** * Get activity (transaction history) for the account * * @param filters - Optional filters (types supported) * @returns Array of Bitcoin transaction activities */ getActivities(filters?: GetActivityFilters): Promise; /** * Lists assets available for the account (native BTC only) * * @returns Assets that have an entity on this Bitcoin chain */ listAssets(): Promise; /** * Returns whether the account's public key is exposed. * * A P2WPKH public key becomes visible the moment a spending transaction is * broadcast — not just when it confirms. This method checks both confirmed * on-chain transactions and pending mempool transactions so that the * vulnerability warning is shown as soon as the user sends, before confirmation. * * @returns true if the account has any confirmed or pending outgoing transaction */ isPubKeyExposed(): Promise; /** * Gets the safety status of the account * * @returns The safety status of the account */ getStatus(): Promise; /** * Sweeps all native BTC from this account to a destination address * * Bitcoin accounts only support their native BTC balance, so empty-vault is * a single sweep transaction with no change output. * * @param destinationAddress The destination Bitcoin address * @returns Summary of the completed empty-vault flow * @throws {InvalidDestinationAddressError} If the destination address is invalid * @throws {NoWithdrawableAssetsError} If no spendable BTC remains after fees */ emptyVault(destinationAddress: string): Promise; /** * Reconciles a withdrawal record against on-chain state (ENG-1791). * * Only operates on non-terminal records (pending/sent). Reads tx confirmation * status from the chain API and the source address balance. Returns the * record unchanged when no transition is warranted; the caller is responsible * for persisting transitions. * * @internal Used by `LibQC.refreshWithdrawalLifecycle`. */ reconcileWithdrawalRecord(record: WithdrawalRecord): Promise; /** * Estimates the fee for sweeping all BTC from this account to a destination address * * @param destinationAddress The destination Bitcoin address * @returns Estimated fee in satoshis * @throws {InvalidDestinationAddressError} If the destination address is invalid * @throws {NoWithdrawableAssetsError} If no spendable BTC remains after fees */ estimateEmptyVaultFee(destinationAddress: string): Promise; /** * Gets the persisted Bitcoin address from the account * * @returns The persisted Bitcoin address */ private getPersistedAddressFromAccount; private getBitcoinNetwork; /** * Validates the destination address and fetches the data needed to build or * estimate a sweep transaction: persisted private key, UTXOs, and fee rate. * * @throws {InvalidDestinationAddressError} If the destination address is invalid * @throws {NoWithdrawableAssetsError} If the account has no spendable balance */ private getSweepContext; }