wallet: stored config (F7) + WalletStatus snapshot + pay/tip readiness guard #75
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/wallet-config-persistence"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stored wallet config (F7) + WalletStatus snapshot + pay/tip readiness guard.
Base is
feat/wallet-create-import(PR #66), notmain: this branch builds onthe wallet create/import + child-lifecycle work that is still unmerged.
What landed
wallet_configtable in the encrypted store (single row; login sealed with thestore data key under
onionwire/wallet-config/v1, on top of SQLCipher). EmptyURL clears the row.
Store::load_wallet_config/save_wallet_config.WalletConfig(redacting Debug) +Wallet::from_config+Wallet::for_boot:stored config wins, env is the migration/fallback path, a stored config that
cannot be used falls back rather than dialling.
Node::start_with_passphrasereads the store before building the wallet.
WalletStatusfor the draw path:connectedonly ever comes from a probe(
Wallet::status= get_address + get_balance), never from config-existence.Node::wallet_statusis the cheap read;Node::wallet_refreshprobes andfolds the result into the snapshot. No background refresh.
Wallet::ping(rpc_url, rpc_login) -> PingResult (ok, status, error)for the F7Test-connection button: loopback + digest rules unchanged, errors redacted and
capped at 120 chars.
readiness(...)+Node::wallet_readiness(is_tip)(async,rt.block_onfromthe key handler): not configured -> NOT_CONFIGURED_MSG;
/tipon no-spend ->existing VIEW_ONLY_MSG before any dial; configured but not connected ->
NOT_CONNECTED_MSG; else ready.
Node::wallet_save_configvalidates, persists, then re-reads so the livewallet and the snapshot follow a Save without a restart.
Node::walletis nowMutex(WALLET)(cloned out before each await) so thewallet can be re-pointed mid-session.
docs/WALLET.md: stored config, boot precedence, freshness rule, guard copy.Local mode stays reserved (child lifecycle is t_69ce8e46, not wired here).
Handoff for the TUI card
WalletStatus configured, connected, last_error, balance_line, receive_addressis passed into draw from
Node::wallet_status().Node::wallet_test_connection(url, login) -> PingResult.Node::wallet_readiness(is_tip) -> Readinesswith.refusal() -> Option<&str>.Node::wallet_config()prefills F7;Node::wallet_save_config(cfg)writes andre-reads.
Verification
cargo check --locked --target x86_64-unknown-linux-gnucleancargo clippy --locked --target x86_64-unknown-linux-gnu --all-targets -- -D warningscleancargo test --locked --target x86_64-unknown-linux-gnugreen; tests/wallet.rs38 passed / 0 failed, whole suite 0 failures (including exact-refusal-copy,
boot precedence over env, login sealed on disk in db/wal/shm, ping
sanitization, connected-only-after-probe).
No password, login or seed appears in any status note, doc line or error string.
The only input path for the wallet was env. Add the same three remote-mode fields as stored config so the F7 screen can set them and headless runs read one source of truth: - `wallet_config` table in the encrypted store (one row; the login is sealed with the store data key under `onionwire/wallet-config/v1`, on top of SQLCipher). Empty URL clears it. `Store::load_wallet_config` / `save_wallet_config`. - `WalletConfig { rpc_url, rpc_login: Zeroizing<String>, no_spend }` with a redacting `Debug`; `Wallet::from_config`, and `Wallet::for_boot` which prefers stored config, falls back to env, and refuses to dial a bad stored endpoint. Node::start* now reads the store before constructing the wallet. - `WalletStatus { configured, connected, last_error, balance_line, receive_address }`: `connected` only ever comes from a probe (`Wallet::status`, get_address + get_balance); config alone leaves it false. `Node::wallet_status` is the cheap draw-path read, `wallet_refresh` the probe that folds into it. - One-shot `Wallet::ping(rpc_url, rpc_login) -> PingResult { ok, status, error }` for the Test-connection button: same loopback/digest rules, errors redacted and capped. - `readiness(configured, connected, no_spend, is_tip) -> Readiness` plus `Node::wallet_readiness` (async, block_on-friendly): not configured → NOT_CONFIGURED_MSG; /tip on a no-spend wallet → VIEW_ONLY_MSG before any dial; configured but not connected → NOT_CONNECTED_MSG; else ready. - `Node::wallet_save_config` persists, validates first, then re-reads so the live wallet and snapshot follow a Save without a restart. - `Node::wallet` is now a Mutex<Wallet> (cloned out before each await) so the wallet can be re-pointed mid-session. Local-mode fields stay reserved: the child lifecycle is t_69ce8e46 and is not wired here. docs/WALLET.md documents the stored config, boot precedence and the exact guard copy. Tests: 38 in tests/wallet.rs including exact-refusal-copy, boot precedence, sealed-on-disk login, ping sanitization and connected-only-after-probe.