import { N as NetworkConfig, M as RpcClient, O as RpcConfig, Q as BlockchainInfo, T as MempoolInfo, X as RawTransaction, U as Utxo, A as AddressType, b as WalletProvider, K as Keystore, D as DerivedKey, S as SignerInfo, Y as WalletBalance, Z as WalletInfo, _ as SendOptions, $ as BroadcastResult } from './types-BttWXI8x.js'; export { B as BroadcastTxOptions, a0 as BuildPsbtArgs, a1 as CURRENT_USER_KEY_SCHEME, c as DEFAULT_WALLET_NETWORK, a2 as DeriveUserKeyOptions, a3 as FeeRateError, G as GetUtxosOptions, a4 as HdDerivedKey, a5 as InsufficientFundsError, I as InvalidAddressError, a6 as InvalidAmountError, d as InvalidMnemonicError, e as InvalidNetworkError, a7 as LEGACY_USER_KEY_SCHEME, a8 as NetworkName, P as PsbtError, a9 as RBF_SEQUENCE, R as REGTEST, aa as ResolveUserKeyOptions, f as RestUtxo, g as RpcEndpoints, ab as RpcError, ac as RpcTransportError, h as SIGNET, i as SUPPORTED_WALLET_CHAINS, j as SUPPORTED_WALLET_NETWORKS, ad as ScantxoutsetResult, ae as ScantxoutsetUnspent, af as SignPsbtArgs, ag as USER_KEY_RECORD_VERSION, k as UserKeyDescriptor, ah as UserKeyScheme, l as UtxoStatus, V as VerifyResult, W as WalletChainName, ai as WalletConfig, m as WalletError, n as WalletLockedError, a as WalletNetworkConfig, o as WalletSigningRequest, aj as assertSupportedUserKeyScheme, p as broadcastTx, q as buildAccountPath, r as buildAddressPath, s as buildDescriptor, ak as buildPsbt, t as deriveAddressFromAccountNode, u as deriveUserKey, al as extractTransaction, v as generateMnemonic, am as getNetwork, w as getUtxos, x as getWalletNetwork, an as isAddressOnNetwork, ao as isLegacyUserKey, ap as listNetworks, y as normalizeMnemonic, z as prepareForWalletSigning, aq as registerNetwork, C as requireUserKey, E as resolveUserKey, F as rpcCall, ar as signPsbt, as as unregisterNetwork, H as userKeyMatches, at as validateAddress, J as validateMnemonic, L as verifyBip322Signature } from './types-BttWXI8x.js'; import * as bitcoin from 'bitcoinjs-lib'; import 'bip32'; declare const SATS_PER_BTC = 100000000n; declare const DUST_THRESHOLD_SATS = 546n; declare const SAFE_DUST_THRESHOLD_SATS = 1000n; declare function btcToSats(btc: string | number): bigint; declare function satsToBtc(sats: bigint): string; declare function coerceSats(value: bigint | number | string): bigint; /** * Legacy P2PKH (m/44') migration safeguards. * * 0.3.0 switched the built-in HD signer to native segwit (p2wpkh, BIP84) and * dropped P2PKH support. The same mnemonic now derives only m/84'/… addresses, * so any balance previously received on the legacy m/44'/… P2PKH chain becomes * invisible to scanning, balance, and send flows. Upgrading without first * sweeping those UTXOs makes the funds *look* gone. * * This module is an opt-in, temporary migration aid: * - `scanLegacyP2pkh()` — read-only detection of non-empty m/44' chains. * - `assertNoStrandedLegacyFunds()` — hard abort when legacy funds exist. * - `sweepLegacy()` — moves all legacy UTXOs to a new p2wpkh address. * * It deliberately re-derives P2PKH *locally* (BIP44 purpose 44) without * re-adding `p2pkh` to the supported `AddressType` union, so the main wallet, * PSBT builder, and signer stay p2wpkh-only. Treat it as a one-time bridge to * run before cutting over, not as a general-purpose legacy wallet. * * Seed hygiene mirrors `derivation.ts`: intermediate seed buffers and derived * private-key bytes are zeroed on a best-effort basis once they are no longer * needed. */ interface LegacyScanOptions { account?: number; passphrase?: string; gapLimit?: number; maxScanIterations?: number; } interface LegacyUserKeyOptions { account?: number; passphrase?: string; count?: number; change?: boolean; } interface LegacyUserKey { readonly index: number; readonly change: boolean; readonly path: string; readonly compressedHex: string; readonly address: string; } interface LegacyUtxo { readonly txid: string; readonly vout: number; readonly valueSats: bigint; readonly address: string; readonly scriptPubKey: string; readonly path: string; readonly change: boolean; readonly addressIndex: number; } interface LegacyScanResult { readonly totalSats: bigint; readonly utxos: LegacyUtxo[]; readonly scannedAddresses: number; readonly accountPath: string; } /** * Derive the PUBLIC keys of one chain of the legacy m/44' account. * * The 0.3.0 cutover stranded more than balances. Anything that reused the * account's secp256k1 pubkey as an identity — most notably a vault's user key * or a Taproot internal key — silently changed with it, because * m/44'/coin'/0'/0/i and m/84'/coin'/0'/0/i are different keys from the same * mnemonic. A consumer that committed the pre-cutover pubkey into a vault or an * on-chain script cannot reproduce it from a post-cutover wallet at ANY index, * and has no way to derive the old key either: `AddressType` is p2wpkh-only, so * `Keystore.fromMnemonic` can no longer reach purpose 44. This is the escape * hatch for exactly that case. * * Prefer `resolveUserKey()` (src/user-key.ts) when you hold the recorded pubkey * and want to know which scheme and path produced it; this is the lower-level * enumeration it is built on. * * Public keys only — no signing capability is returned, and the private material * derived along the way is wiped before returning. Sweeping legacy funds is * still `sweepLegacy()`; this is for reconstructing a legacy IDENTITY. */ declare function deriveLegacyUserKeys(mnemonic: string, network: NetworkConfig, opts?: LegacyUserKeyOptions): LegacyUserKey[]; /** * Detect funds stranded on the legacy m/44' (P2PKH) chain for `mnemonic`. * Read-only: derives legacy addresses for a gap-limit window, scans the UTXO * set, and reports the total. The derived private material is wiped before * returning. */ declare function scanLegacyP2pkh(mnemonic: string, network: NetworkConfig, rpc: RpcClient, opts?: LegacyScanOptions): Promise; /** * Guard intended for first-run / upgrade paths: throws if any legacy P2PKH * funds are discovered so they cannot silently strand under the p2wpkh-only * signer. Resolves quietly when the legacy chain is empty. */ declare function assertNoStrandedLegacyFunds(mnemonic: string, network: NetworkConfig, rpc: RpcClient, opts?: LegacyScanOptions): Promise; interface SweepLegacyArgs extends LegacyScanOptions { mnemonic: string; network: NetworkConfig; rpc: RpcClient; destination: string; feeRate: number; broadcast?: boolean; } interface SweepLegacyResult { readonly txid: string | null; readonly hex: string; readonly sweptSats: bigint; readonly feeSats: bigint; readonly inputCount: number; readonly destination: string; } /** * Sweep every discovered legacy m/44' (P2PKH) UTXO into a single output at * `destination` (your new p2wpkh address). Builds, signs, and — unless * `broadcast: false` — broadcasts the transaction. * * Legacy inputs are non-witness, so each parent transaction is fetched in full, * verified against the scan result, and attached as `nonWitnessUtxo`. The * derived private material is wiped before returning. */ declare function sweepLegacy(args: SweepLegacyArgs): Promise; declare class BitcoinCoreRpcClient implements RpcClient { #private; constructor(config: RpcConfig); call(method: string, params?: readonly unknown[]): Promise; toJSON(): Record; } interface ScannedUtxo { txid: string; vout: number; valueSats: bigint; scriptPubKey: string; height: number; confirmations: number; coinbase: boolean; } /** Tunables for the `scantxoutset` retry loop; every field has a default. */ interface ScanRetryOptions { /** Total attempts, including the first (default 4). `1` disables retrying. */ attempts?: number; /** Delay before the first retry, doubling thereafter (default 2000ms). */ baseDelayMs?: number; /** Ceiling for the backoff delay (default 8000ms). */ maxDelayMs?: number; /** Injectable sleep, so tests need not wait in real time. */ sleepImpl?: (ms: number) => Promise; } /** Options for {@link scanForUtxos}. */ interface ScanForUtxosOptions { retry?: ScanRetryOptions; } declare function scanForUtxos(client: RpcClient, descriptors: readonly string[], options?: ScanForUtxosOptions): Promise<{ utxos: ScannedUtxo[]; scanHeight: number; }>; declare function broadcastRawTransaction(client: RpcClient, rawHex: string): Promise; declare function getRawTransaction(client: RpcClient, txid: string): Promise; declare function getMempoolInfo(client: RpcClient): Promise; declare function getBlockchainInfo(client: RpcClient): Promise; type FeeRateSource = "node" | "fallback"; interface FeeEstimate { satPerVb: number; source: FeeRateSource; } declare function estimateFeeRateTagged(client: RpcClient, targetBlocks?: number, fallbackSatVb?: number): Promise; declare function estimateFeeRate(client: RpcClient, targetBlocks?: number, fallbackSatVb?: number): Promise; declare function createDefaultRpcClient(config: RpcConfig): RpcClient; interface CoinSelectionInput { utxos: readonly Utxo[]; amountSats: bigint; feeRate: number; inputAddressType: AddressType; outputAddressType: AddressType; changeAddressType?: AddressType; sweep?: boolean; } interface CoinSelectionResult { inputs: Utxo[]; feeSats: bigint; changeSats: bigint; outputCount: number; vsize: number; } declare function estimateVsize(inputType: AddressType, outputTypes: readonly AddressType[], nInputs: number): number; declare function selectCoins(opts: CoinSelectionInput): CoinSelectionResult; /** * KeystoreProvider — built-in WalletProvider backed by BIP39/BIP32 HD derivation. * * Wraps `Keystore` so `Wallet` can consume it via the generic `WalletProvider` interface, * preserving all Keystore security guarantees (private fields, lock/wipe, safe serialization). * * Usage: * const keystore = Keystore.fromSeedBytes(seed, network, 'p2wpkh', 0); * const provider = new KeystoreProvider(keystore); * const wallet = new Wallet({ provider, rpc }); */ declare class KeystoreProvider implements WalletProvider { #private; readonly name = "keystore"; readonly supportsInternalSend = true; constructor(keystore: Keystore); get network(): NetworkConfig; get addressType(): AddressType; get account(): number; get fingerprint(): string; get accountPath(): string; get accountXpub(): string; get locked(): boolean; deriveReceiveAddresses(count: number): DerivedKey[]; deriveChangeAddresses(count: number): DerivedKey[]; signPsbt(psbt: bitcoin.Psbt, inputs: readonly Utxo[]): void; buildDescriptor(change: boolean): string; getSignerInfo(): SignerInfo; lock(): void; toJSON(): Record; } type WalletState = "new" | "synced"; interface WalletOptions { provider?: WalletProvider; keystore?: Keystore; rpc: RpcClient; gapLimit?: number; maxSyncIterations?: number; scanRetry?: ScanRetryOptions; } declare class Wallet { #private; constructor(opts: WalletOptions); get provider(): WalletProvider; get locked(): boolean; get state(): WalletState; get receiveAddress(): string; get changeAddress(): string; get balance(): WalletBalance; get utxos(): readonly Utxo[]; get immatureUtxos(): readonly Utxo[]; get signers(): readonly SignerInfo[]; get info(): WalletInfo; sync(): Promise; send(opts: SendOptions): Promise; lock(): void; toJSON(): Record; } interface AggregatorConfig { network: string; rpc: RpcClient; passphrase?: string; gapLimit?: number; maxSyncIterations?: number; scanRetry?: ScanRetryOptions; } interface AccountSpec { addressType: AddressType; account?: number; provider?: string; } interface AggregatorInfo { network: string; signers: readonly SignerInfo[]; wallets: number; } declare class WalletAggregator { #private; private constructor(); static fromMnemonic(mnemonic: string, config: AggregatorConfig): WalletAggregator; static fromSeed(seed: Uint8Array, config: AggregatorConfig): WalletAggregator; static createNew(config: AggregatorConfig, strength?: 128 | 160 | 192 | 224 | 256): { aggregator: WalletAggregator; mnemonic: string; }; get info(): AggregatorInfo; get signers(): readonly SignerInfo[]; get wallets(): readonly Wallet[]; get locked(): boolean; addAccount(spec: AccountSpec): Wallet; addProvider(provider: WalletProvider): Wallet; getWallet(spec: AccountSpec): Wallet; wallet(spec: AccountSpec): Wallet; syncAll(): Promise; aggregateBalance(): WalletBalance; aggregateUtxos(): Utxo[]; lock(): void; toJSON(): Record; } export { type AccountSpec, AddressType, type AggregatorConfig, type AggregatorInfo, BitcoinCoreRpcClient, BlockchainInfo, BroadcastResult, type CoinSelectionInput, type CoinSelectionResult, DUST_THRESHOLD_SATS, DerivedKey, type FeeEstimate, type FeeRateSource, Keystore, KeystoreProvider, type LegacyScanOptions, type LegacyScanResult, type LegacyUserKey, type LegacyUserKeyOptions, type LegacyUtxo, MempoolInfo, NetworkConfig, RawTransaction, RpcClient, RpcConfig, SAFE_DUST_THRESHOLD_SATS, SATS_PER_BTC, type ScanForUtxosOptions, type ScanRetryOptions, type ScannedUtxo, SendOptions, SignerInfo, type SweepLegacyArgs, type SweepLegacyResult, Utxo, Wallet, WalletAggregator, WalletBalance, WalletInfo, type WalletOptions, WalletProvider, type WalletState, assertNoStrandedLegacyFunds, broadcastRawTransaction, btcToSats, coerceSats, createDefaultRpcClient, deriveLegacyUserKeys, estimateFeeRate, estimateFeeRateTagged, estimateVsize, getBlockchainInfo, getMempoolInfo, getRawTransaction, satsToBtc, scanForUtxos, scanLegacyP2pkh, selectCoins, sweepLegacy };