Keystore
What the keystore stores
Sealed secrets plus plaintext address rows; prefer SQLite at scale.
Overview
@gray3/keystore implements GrayStorage for GrayClient. Secrets are sealed; address metadata stays plaintext for fast list/search.
Data split
| Data | Where | Encrypted? |
|---|---|---|
| mnemonic / private key | secrets table / KV secret slot | Yes when encryption: true (default) |
| wallets, slots, accounts (addresses, paths, labels, Monero balance/activity cache) | SQLite rows or KV meta | No |
At scale (100 wallets × 100 accounts): use sqlite. KV (localStorage / AsyncStorage) is only for small wallet counts. The SQLite backend for each platform is listed in Platforms.
Wallet snapshot shape
getWallet returns a full snapshot (decrypts secret when unlocked):
ts
{
id: string;
label: string;
kind: "mnemonic" | "private_key" | "watch";
paths?: { evm?: string; [chainId]?: string };
enabledChains?: GrayChainId[];
accounts: Array<{ id: string; index: number; label?: string }>;
chains: Array<{
id: string;
accountId: string;
chainId: GrayChainId;
address: string;
index: number;
path: string;
family: ChainFamily;
allAddresses?: Array<{ address: string; type: string }>;
}>;
// slots[].monero?: { balance, activity, height, syncedAt, … }
secret:
| { kind: "mnemonic"; mnemonic: string; bip39Passphrase?: string }
| { kind: "private_key"; privateKey: string; chainId: GrayChainId }
| { kind: "watch" };
createdAt?: string;
updatedAt?: string;
}Usage with client
js
const storage = await GrayKeystore.create({
sqlite: { path: "./gray-wallets.db" }, // Node.js; needs better-sqlite3
password: pin,
});
const client = await GrayClient.create({ storage });
const wallet = await client.wallets.create({ label: "Main", password: pin });