/** * In-house wallet group store. * * Storage: ~/.fourmm/wallets/wallet-store.json (mode 0600), JSON-encoded. * Each wallet's privateKey is AES-encrypted with the master password. * * File shape: * { * encrypted: true, * passwordCheck: "...", // AES('ALMM_PASSWORD_OK', password) * groups: { * "1": { groupId, name, wallets: [...], note, createdAt, updatedAt }, * ... * } * } * * All public functions take the master password as an explicit first argument. * There is NO module-level password state: that makes testing easier, hides * fewer dependencies, and lets Week-2 code pass different passwords in the * same process (e.g. import + decrypt two different vaults). * * Write path is atomic (write .tmp, rename) to avoid half-written files. */ import type { Address, Hex } from 'viem'; /** A single wallet inside a group */ export type StoredWallet = { /** EVM checksummed address */ address: Address; /** AES-encrypted hex private key (with 0x prefix before encryption) */ encryptedPrivateKey: string; /** Free-form note */ note: string; }; /** A wallet group (collection of wallets under a shared name) */ export type WalletGroup = { /** Numeric group ID (auto-assigned) */ groupId: number; /** Group name */ name: string; /** Free-form description */ note: string; /** Wallets in this group */ wallets: StoredWallet[]; /** ISO 8601 timestamps */ createdAt: string; updatedAt: string; }; /** Root file format */ export type WalletStoreFile = { encrypted: true; passwordCheck: string; groups: Record; }; /** Group summary (what `list-groups` returns — no wallet contents) */ export type WalletGroupSummary = Omit & { walletCount: number; }; /** Does a wallet store file already exist? */ export declare function storeExists(): boolean; /** * Load the wallet store. * * - Returns `null` if the store doesn't exist yet. Read-only callers * (e.g. `list-groups`) should treat this as "no groups". * - Throws if the store exists but the password doesn't match. * - **Never writes to disk.** Callers that want to create a new store * must call `initStore(password)` explicitly. */ export declare function loadStore(password: string): WalletStoreFile | null; /** * Create a new empty wallet store, encrypted with the given password. * * Throws if a store file already exists. Callers should check `storeExists()` * or use `loadOrInitStore()` if they want idempotent creation. */ export declare function initStore(password: string): WalletStoreFile; /** * Convenience: load the store, or init an empty one if it doesn't exist. * Used by write operations (`createGroup`, etc.). */ export declare function loadOrInitStore(password: string): WalletStoreFile; /** Persist the wallet store atomically */ export declare function saveStore(store: WalletStoreFile): void; /** List all groups (summary form). Returns empty array if no store. */ export declare function listGroups(password: string): WalletGroupSummary[]; /** Get a single group by ID. Returns undefined if store or group missing. */ export declare function getGroup(password: string, groupId: number): WalletGroup | undefined; /** * Create a new wallet group with N freshly-generated wallets. * Private keys are encrypted at rest immediately. */ export declare function createGroup(password: string, options: { name: string; count: number; note?: string | undefined; }): WalletGroup; /** Add newly-generated wallets to an existing group */ export declare function addGeneratedWallets(password: string, groupId: number, count: number): StoredWallet[]; /** Add a wallet from an existing private key */ export declare function addWalletFromPrivateKey(password: string, groupId: number, privateKey: Hex, note?: string): StoredWallet; /** Delete an entire wallet group by ID. */ export declare function deleteGroup(password: string, groupId: number): void; /** Remove a single wallet from a group by address. */ export declare function removeWalletFromGroup(password: string, groupId: number, address: Address): void; /** Decrypt a wallet's private key (only for in-process signing — never log) */ export declare function decryptPrivateKey(stored: StoredWallet, password: string): Hex; //# sourceMappingURL=store.d.ts.map