wallet: stored config (F7) + WalletStatus snapshot + pay/tip readiness guard #75

Merged
sirius merged 1 commit from feat/wallet-config-persistence into feat/wallet-create-import 2026-09-15 03:49:07 +00:00
Owner

Stored wallet config (F7) + WalletStatus snapshot + pay/tip readiness guard.

Base is feat/wallet-create-import (PR #66), not main: this branch builds on
the wallet create/import + child-lifecycle work that is still unmerged.

What landed

  • wallet_config table in the encrypted store (single row; login sealed with the
    store data key under onionwire/wallet-config/v1, on top of SQLCipher). Empty
    URL 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_passphrase
    reads the store before building the wallet.
  • WalletStatus for the draw path: connected only ever comes from a probe
    (Wallet::status = get_address + get_balance), never from config-existence.
    Node::wallet_status is the cheap read; Node::wallet_refresh probes and
    folds the result into the snapshot. No background refresh.
  • Wallet::ping(rpc_url, rpc_login) -> PingResult (ok, status, error) for the F7
    Test-connection button: loopback + digest rules unchanged, errors redacted and
    capped at 120 chars.
  • readiness(...) + Node::wallet_readiness(is_tip) (async, rt.block_on from
    the key handler): not configured -> NOT_CONFIGURED_MSG; /tip on no-spend ->
    existing VIEW_ONLY_MSG before any dial; configured but not connected ->
    NOT_CONNECTED_MSG; else ready.
  • Node::wallet_save_config validates, persists, then re-reads so the live
    wallet and the snapshot follow a Save without a restart.
  • Node::wallet is now Mutex(WALLET) (cloned out before each await) so the
    wallet 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_address
    is passed into draw from Node::wallet_status().
  • Node::wallet_test_connection(url, login) -> PingResult.
  • Node::wallet_readiness(is_tip) -> Readiness with .refusal() -> Option<&str>.
  • Node::wallet_config() prefills F7; Node::wallet_save_config(cfg) writes and
    re-reads.

Verification

  • cargo check --locked --target x86_64-unknown-linux-gnu clean
  • cargo clippy --locked --target x86_64-unknown-linux-gnu --all-targets -- -D warnings clean
  • cargo test --locked --target x86_64-unknown-linux-gnu green; tests/wallet.rs
    38 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.

Stored wallet config (F7) + WalletStatus snapshot + pay/tip readiness guard. Base is `feat/wallet-create-import` (PR #66), not `main`: this branch builds on the wallet create/import + child-lifecycle work that is still unmerged. What landed - `wallet_config` table in the encrypted store (single row; login sealed with the store data key under `onionwire/wallet-config/v1`, on top of SQLCipher). Empty URL 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_passphrase` reads the store before building the wallet. - `WalletStatus` for the draw path: `connected` only ever comes from a probe (`Wallet::status` = get_address + get_balance), never from config-existence. `Node::wallet_status` is the cheap read; `Node::wallet_refresh` probes and folds the result into the snapshot. No background refresh. - `Wallet::ping(rpc_url, rpc_login) -> PingResult (ok, status, error)` for the F7 Test-connection button: loopback + digest rules unchanged, errors redacted and capped at 120 chars. - `readiness(...)` + `Node::wallet_readiness(is_tip)` (async, `rt.block_on` from the key handler): not configured -> NOT_CONFIGURED_MSG; `/tip` on no-spend -> existing VIEW_ONLY_MSG before any dial; configured but not connected -> NOT_CONNECTED_MSG; else ready. - `Node::wallet_save_config` validates, persists, then re-reads so the live wallet and the snapshot follow a Save without a restart. - `Node::wallet` is now `Mutex(WALLET)` (cloned out before each await) so the wallet 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_address` is passed into draw from `Node::wallet_status()`. - `Node::wallet_test_connection(url, login) -> PingResult`. - `Node::wallet_readiness(is_tip) -> Readiness` with `.refusal() -> Option<&str>`. - `Node::wallet_config()` prefills F7; `Node::wallet_save_config(cfg)` writes and re-reads. Verification - `cargo check --locked --target x86_64-unknown-linux-gnu` clean - `cargo clippy --locked --target x86_64-unknown-linux-gnu --all-targets -- -D warnings` clean - `cargo test --locked --target x86_64-unknown-linux-gnu` green; tests/wallet.rs 38 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.
wallet: stored config (F7), WalletStatus snapshot, pay/tip readiness guard
All checks were successful
ci / test (pull_request) Successful in 4m22s
ci / sdk (pull_request) Successful in 1m15s
d7e91f850a
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.
sirius merged commit ee5b25488b into feat/wallet-create-import 2026-09-15 03:49:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!75
No description provided.