tui: F6 opens the wallet screen instead of exiting when no wallet is configured #161

Merged
sirius merged 2 commits from onionwire/t_da08817e-onionwire-tui-f6-exits-the-app-when-no-w into main 2026-09-27 02:58:22 +00:00
Owner

What this fixes

F6 on an install with no wallet RPC configured and no profile xmr_addr used to
terminate the process:

onionwire: no receive address — set profile xmr or ONIONWIRE_WALLET_RPC

App::open_wallet propagated that Err with ?; it ran out of App::run and out
of boot() in src/main.rs, which printed it and exited 1. An unconfigured wallet
is a normal state on that screen, not a fatal one — App::open_wallets_settings
(F9) already degrades the same call with unwrap_or_default().

What changed (src/tui.rs, App::open_wallet only)

  • The address call now degrades to an empty receive_addr instead of returning an
    error, so F6 always opens Screen::Wallet.

  • It leaves a status note naming the way forward:

    no wallet configured · c create or i import, or set ONIONWIRE_WALLET_RPC
    

    Delegating to the existing wallet::NOT_CONNECTED_MSG when the wallet is
    configured but the call still failed, so a broken endpoint is not reported as an
    absent one.

  • balance and transfers are untouched. Node::wallet_receive_address and
    Node::invoice_address are untouched.

Which assumption this makes about F7

On the base commit (a1f5c87) KeyCode::F(7) has no binding at all — the only
thing that mentions F7 is wallet::NOT_CONFIGURED_MSG, copy that is asserted
verbatim elsewhere and that this card must not touch. So the note does not tell
the user to press F7: it names the create/import keys that exist on this very screen
today (c/i, both already in the screen's own help line) plus the env var, which
is true on this base and stays true after the F7 setup screen lands. If you would
rather the note name F7 once that screen exists, it is a one-line change to
App::WALLET_SETUP_NOTE.

Tests (mod wallet_store_tests, real App::draw at 80x24)

  1. f6_on_a_bare_install_opens_the_wallet_screen_instead_of_exiting — handle_key(F6)
    returns Ok, the screen is Screen::Wallet { .. }, receive_addr is empty and
    status_note is Some (contains no wallet configured). Red before the fix:
    the call returned Err("no receive address — set profile xmr or ONIONWIRE_WALLET_RPC").
  2. f6_on_a_bare_install_never_draws_the_error_and_states_the_way_forward — the frame
    drawn through App::draw never contains the node's error text, and after Esc the
    main view's status line really renders the note.
  3. f6_on_an_install_with_a_wallet_still_fills_the_receive_address — control: with a
    profile xmr_addr (the documented mainnet address tests/wallet.rs uses),
    receive_addr is that address and status_note stays None. This passed before
    the change and still does.
  4. wallet_offset_tests::only_seen_leaves_the_offset_notice_for_the_wallet asserted
    the propagation itself (expect_err on the missing wallet). It now asserts the
    screen the full word reaches (Screen::Wallet { .. }); the prefix half is unchanged.

What F6 now shows on a bare install, one line: the wallet screen (title wallet,
its own s/x/p/c/i/r help line) — it opens instead of exiting, with an empty address
and the note above on the main view's status line.

Evidence

$ export TMPDIR=/home/lancelot/.hermes/tmp/onionwire-tui
$ cargo test --locked
test result: ok. 105 passed; 0 failed   (lib)
... 35 suites, 475 tests, 0 failed; exit 0

$ cargo clippy --locked --all-targets -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.59s; exit 0

Found while doing this: the wallet screen's body is clipped (not fixed here)

Dumping the real frame through App::draw at 80x24 shows the Screen::Wallet body
(address / balance / recent transfers) is not rendered at all — with a
receive address or without:

┌wallet────────────────────────────────────────────────────────────────────────┐
└──────────────────────────────────────────────────────────────────────────────┘
                            (16 blank rows — nothing drawn)
┌──────────────────────────────────────────────────────────────────────────────┐
└──────────────────────────────────────────────────────────────────────────────┘
s start child  x stop child  p probe  c create  i import  r qr  Esc back

Cause: draw_wallet renders that Paragraph into cols[2] of
Layout::vertical([Length(2), Min(4), Length(2), Length(3), Length(1)]) — a
2-row slot whose borders consume both rows. The Min(4) slot (cols[1]) is the
one that gets the height and is left empty at src/tui.rs:5327-5381. Pre-existing
on main, independent of this fix, and out of the allowed scope of this card
(App::open_wallet + test fns only), so it is reported rather than patched here.
It is also why the visible consequence of this fix on the F6 screen itself is "the
screen opens, the address field is empty" and not a printed no address: the note
lands in status_note, which the main view's status line renders.

Files: src/tui.rs only (+148/-8).

## What this fixes `F6` on an install with no wallet RPC configured and no profile `xmr_addr` used to terminate the process: ``` onionwire: no receive address — set profile xmr or ONIONWIRE_WALLET_RPC ``` `App::open_wallet` propagated that `Err` with `?`; it ran out of `App::run` and out of `boot()` in `src/main.rs`, which printed it and exited 1. An unconfigured wallet is a normal state on that screen, not a fatal one — `App::open_wallets_settings` (`F9`) already degrades the same call with `unwrap_or_default()`. ## What changed (`src/tui.rs`, `App::open_wallet` only) - The address call now degrades to an empty `receive_addr` instead of returning an error, so `F6` always opens `Screen::Wallet`. - It leaves a status note naming the way forward: ``` no wallet configured · c create or i import, or set ONIONWIRE_WALLET_RPC ``` Delegating to the existing `wallet::NOT_CONNECTED_MSG` when the wallet *is* configured but the call still failed, so a broken endpoint is not reported as an absent one. - `balance` and `transfers` are untouched. `Node::wallet_receive_address` and `Node::invoice_address` are untouched. ### Which assumption this makes about F7 On the base commit (`a1f5c87`) `KeyCode::F(7)` has **no binding at all** — the only thing that mentions F7 is `wallet::NOT_CONFIGURED_MSG`, copy that is asserted verbatim elsewhere and that this card must not touch. So the note does **not** tell the user to press F7: it names the create/import keys that exist on this very screen today (`c`/`i`, both already in the screen's own help line) plus the env var, which is true on this base and stays true after the F7 setup screen lands. If you would rather the note name F7 once that screen exists, it is a one-line change to `App::WALLET_SETUP_NOTE`. ## Tests (`mod wallet_store_tests`, real `App::draw` at 80x24) 1. `f6_on_a_bare_install_opens_the_wallet_screen_instead_of_exiting` — `handle_key(F6)` returns `Ok`, the screen is `Screen::Wallet { .. }`, `receive_addr` is empty and `status_note` is `Some` (contains `no wallet configured`). **Red before the fix**: the call returned `Err("no receive address — set profile xmr or ONIONWIRE_WALLET_RPC")`. 2. `f6_on_a_bare_install_never_draws_the_error_and_states_the_way_forward` — the frame drawn through `App::draw` never contains the node's error text, and after `Esc` the main view's status line really renders the note. 3. `f6_on_an_install_with_a_wallet_still_fills_the_receive_address` — control: with a profile `xmr_addr` (the documented mainnet address `tests/wallet.rs` uses), `receive_addr` is that address and `status_note` stays `None`. This passed before the change and still does. 4. `wallet_offset_tests::only_seen_leaves_the_offset_notice_for_the_wallet` asserted the propagation itself (`expect_err` on the missing wallet). It now asserts the screen the full word reaches (`Screen::Wallet { .. }`); the prefix half is unchanged. What `F6` now shows on a bare install, one line: the wallet screen (title `wallet`, its own `s/x/p/c/i/r` help line) — it opens instead of exiting, with an empty address and the note above on the main view's status line. ## Evidence ``` $ export TMPDIR=/home/lancelot/.hermes/tmp/onionwire-tui $ cargo test --locked test result: ok. 105 passed; 0 failed (lib) ... 35 suites, 475 tests, 0 failed; exit 0 $ cargo clippy --locked --all-targets -- -D warnings Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.59s; exit 0 ``` ## Found while doing this: the wallet screen's body is clipped (not fixed here) Dumping the real frame through `App::draw` at 80x24 shows the `Screen::Wallet` body (`address` / `balance` / `recent transfers`) is **not rendered at all** — with a receive address or without: ``` ┌wallet────────────────────────────────────────────────────────────────────────┐ └──────────────────────────────────────────────────────────────────────────────┘ (16 blank rows — nothing drawn) ┌──────────────────────────────────────────────────────────────────────────────┐ └──────────────────────────────────────────────────────────────────────────────┘ s start child x stop child p probe c create i import r qr Esc back ``` Cause: `draw_wallet` renders that `Paragraph` into `cols[2]` of `Layout::vertical([Length(2), Min(4), Length(2), Length(3), Length(1)])` — a 2-row slot whose borders consume both rows. The `Min(4)` slot (`cols[1]`) is the one that gets the height and is left empty at `src/tui.rs:5327-5381`. Pre-existing on `main`, independent of this fix, and **out of the allowed scope of this card** (`App::open_wallet` + test fns only), so it is reported rather than patched here. It is also why the visible consequence of this fix on the F6 screen itself is "the screen opens, the address field is empty" and not a printed `no address`: the note lands in `status_note`, which the main view's status line renders. Files: `src/tui.rs` only (+148/-8).
tui: F6 opens the wallet screen instead of exiting when no wallet is configured
All checks were successful
ci / test (pull_request) Successful in 6m44s
ci / sdk (pull_request) Successful in 1m33s
android-ci / android (pull_request) Successful in 12m2s
ci / fuzz (pull_request) Successful in 18m34s
5fcd4ed643
App::open_wallet propagated the node's "no receive address" error with `?`,
so on an install with no wallet RPC configured and no profile xmr the Err
travelled out of App::run and out of boot(), and the process exited 1. The
same call already degrades to an empty address on F9.

Degrade it here too, and leave a status note that names the way forward:
this screen's own `c`/`i` create/import keys plus ONIONWIRE_WALLET_RPC.
A configured-but-failing endpoint gets the existing NOT_CONNECTED_MSG
instead of the unconfigured copy. balance and transfers are unchanged.

Tests: F6 on a bare install opens Screen::Wallet with an empty receive_addr,
a status note, and no error text in the frame drawn through App::draw; the
frame after Esc back to Main really renders the note. The control case (a
profile xmr address) still fills receive_addr and sets no note. The existing
offset-notice test asserted the propagation itself and now asserts the screen
it reaches instead.
Merge branch 'main' into onionwire/t_da08817e-onionwire-tui-f6-exits-the-app-when-no-w
Some checks failed
android-ci / android (pull_request) Has been cancelled
ci / test (pull_request) Successful in 6m6s
ci / sdk (pull_request) Successful in 1m21s
ci / fuzz (pull_request) Successful in 5m3s
4ff5af3fab
sirius merged commit 73130b443f into main 2026-09-27 02:58:22 +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!161
No description provided.