Skip to main content

Module keystore

Module keystore 

Source
Expand description

Encrypted wallet persistence.

Default: Web3 Secret Storage v3 JSON (Foundry/Geth/MetaMask-interoperable), resolved under $XDG_DATA_HOME/taskfast/wallets/ so a wallet generated here can be imported by cast wallet import without conversion.

This module owns two concerns and nothing else:

  1. Path resolution — XDG-compliant directory layout with 0700 perms on the containing dir and 0600 perms on the keyfile.
  2. Encrypt/decrypt — thin wrappers around PrivateKeySigner::encrypt_keystore / decrypt_keystore, which delegate to eth-keystore for the scrypt+AES-128-CTR pipeline.

§Future: OS keychain

KeySource::Keychain is reserved but not yet implemented. When it lands, it’ll go behind a keyring cargo feature so the default build has no dbus/secret-service transitive deps. CLI sandboxes that need portable persistence should use the file backend; keychain support is targeted at interactive dev boxes.

Enums§

KeySource
Where a wallet private key is (or will be) stored.
KeystoreError

Functions§

default_keyfile_name
Canonical filename for a wallet keyed by its address: lowercase hex, no 0x prefix, .json suffix. Matches the shape cast wallet import produces when given --keystore-dir without an explicit name.
default_keyfile_path
Resolves the default keyfile path for a given address under the default keystore dir.
default_keystore_dir
Returns $XDG_DATA_HOME/taskfast/wallets, falling back to $HOME/.local/share/taskfast/wallets when XDG is unset.
generate_and_save
Generates a fresh random signer, encrypts it, writes it to the default path for its address, and returns (signer, path). The most common init flow: taskfast init --generate-wallet.
load
Load a signer by KeySource — dispatches to the file backend today. Keychain support will slot in here under a cargo feature.
load_signer
Decrypts the keystore at path with password and returns the signer.
save_signer
Encrypts signer with password and writes it to path, creating parent directories as needed. Overwrites any existing file at the same path — callers wanting idempotency should check Path::exists first.