WalletAddressCache
Persistent, per-network store for the wallet's public addresses.
The same BIP-39 seed produces different bech32m-encoded addresses on different Midnight networks, because the network prefix (mn_addr_preprod vs mn_addr_undeployed vs mn_addr_preview) is baked into the encoding. This cache keeps one entry per network so the wallet can display the correct address for whatever network the user has selected, without needing to re-derive from the seed (which requires biometric auth).
Storage: JSON file at <app filesDir>/kuira_wallet_address.json. Layout:
{
"UNDEPLOYED": {"unshielded": "...", "shielded": "..."},
"PREPROD": {"unshielded": "...", "shielded": "..."}
}Missing networks are absent from the map. Legacy single-network files (from before per-network storage landed) are migrated on first read.
When is a network's entry populated?
At onboarding (new wallet or restore): the current network's entry is written after
storeSeedsucceeds.At network switch: if the target network isn't in the cache, the
MainActivityswitch flow prompts biometric, loads the seed, derives fresh addresses, saves them, then restarts the app. The cache is never populated without the user's seed being unlocked.
Security note: addresses are public data. No encryption here — unlike the seed, losing this file just means a one-time re-derivation (which does require biometric). Storage lives in the same filesDir as the seed, which is excluded from Auto Backup via backup_rules.xml.
Threading: all I/O runs on Dispatchers.IO.
Functions
Load cached addresses for network. Returns null if this network has no cached entry yet (e.g., onboarding ran on a different network and no switch has happened).