onionwire/docs/TUI.md
agent 93deaa5309
All checks were successful
ci / test (pull_request) Successful in 6m39s
ci / sdk (pull_request) Successful in 1m31s
android-ci / android (pull_request) Successful in 12m57s
ci / fuzz (pull_request) Successful in 5m3s
wallet: unlocked balance, restore height, outgoing rows, send, view-only import
`get_balance` carries two numbers and the wallet screen only showed one:
`Node::wallet_balance_line` now reads both out of a single answer
(`balance {total} XMR · unlocked {unlocked} XMR`, the `balance 0 XMR` prefix
kept, total-only when the RPC reports no unlocked half), and
`Node::wallet_unlocked_balance` reports the unlocked half on its own with
`wallet_balance`'s `off` / `err` sentinels. `wallet_balance` keeps its shape.

`get_transfers` sends `out: true` and parses the `out` bucket, so `TransferRow`
carries `direction` (`in`, `out`, `pending`; a pending item's own `type` wins)
and the screen can tell a spent transfer from a received one.

`Wallet::restore_wallet` / `Node::wallet_restore` take an optional
`restore_height` beside the seed offset: blank omits the field, a typed `0` is
sent as `0`, `Some(n)` is a JSON number, and a non-numeric height is a local
refusal (`restore height must be a block number`). A height after the first
receive hides the older funds and this version has no rescan — the TUI says so
on its own step, whose footer is not the offset's.

`Node::wallet_send` spends to a pasted address: `check_address`, then
`xmr_to_atomic`, then `Wallet::transfer` — no friend, no `tip` frame, no chat
line, no payment row. The outgoing transfer list is the record. `pay::check_address`
and `Wallet::transfer` own the gates, so a view-only or unsynced refusal is the
string they already return.

`Wallet::import_view_only` / `Node::wallet_import_view_only` watch an address
through `generate_from_keys` with no `spendkey` in the request at all: same
filename/password refusals, `check_address`, a 64-hex view key or a local
refusal, no 64th catalogue column. The view key is typed into a hidden entry
(twice), is never sealed, never logged and never on an argv, and the screen
wipes it on every exit.

TUI: `n` sends (address, amount, then `SEND`; Esc spends nothing), `y` copies
the receive address over OSC 52, `v` imports a view-only wallet (no seed, so no
`SEEN` gate), and the seed import gained a `restore height` step between the
offset and the file passphrase. The wallet footer and its help line carry the
new keys and keep every old token. The F6 body renders in the flexible region —
a bordered block in the two-row slot it used drew its borders and clipped the
whole body, address and balance line included.

SDK: `wallet_unlocked_balance`, `wallet_send`, `wallet_view_only`,
`import_seed(password, seed, offset, height)` and
`import_view_only(password, address, view_key, height)`, plus
`TransferRow.direction`. `wallet_balance`, `import_wallet` and
`import_wallet_with_offset` are untouched.

Docs: WALLET (unlocked vs total, restore height, outgoing rows, local send,
view-only import), THREAT_MODEL (a view key entered at import is a secret and a
view-only file is not a spend authority), TUI (footer + the new keys and steps),
README (one sentence).

Tests: recorded-request cases in `tests/wallet.rs` (height as a number and
omitted when blank, `generate_from_keys` carries the view key and no spendkey,
`get_transfers` asks for `out`, `wallet_send` reaches `transfer` and never
`tip`, a bad view key never dials), node-level line/unlocked pairs from one
dial, and TUI step tests for the send, copy, height and view-only flows.

No new crate, no Cargo change, no android/ change.
2026-09-25 02:23:09 -04:00

9.8 KiB
Raw Blame History

OnionWire TUI

Operator map of the Linux terminal UI. Bindings live in src/tui.rs (function_key_for, parse_cmd, per-screen match arms). This is not a screenshot dump.

Run onionwire in a real terminal. ONIONWIRE_ASCII or NO_COLOR switches ASCII chrome.

Screens

enum Screen in src/tui.rs:

Screen How you get there What it is
Main boot Roster, chat, composer
Share F2 Invite string (onionwire:v1:…)
Paste F3 Paste a friend's invite
Approve paste of unknown k y accept / n reject
Rotate F4 Type ROTATE to change the onion locator
RotatePrekey F8 Type ROTATE to hard-cut the Noise static
Wipe /wipe or /wipe-all Type WIPE or WIPEALL
Profile /profile Edit name, bio, optional Monero address
ConfirmKeys / Passphrase /backup, /restore Type BACKUP/RESTORE, then passphrase
Wallet F6 Receive QR, balance, transfers, child, chain source
WalletSelect F6 w Saved wallets, pick one or create one
WalletSetup F6 c / i / n / v, or /wallet create / import Spend warning, seed, optional seed-offset passphrase, restore height, import, send, view-only import
WalletsSettings F9 or /settings Discovery menu (does not replace F-keys)
PeerPayments F9 then p Peer-scoped /pay / /tip history
Quit Ctrl-Q Type CLEAR or QUIT

Help (?) is an overlay, not a screen. /who / F5 is an overlay on Main.

There is no F7. Function keys that fire from Main, the settings menu, and peer-payments are:

Key FunctionKey Action
F2 Share Invite
F3 Paste Paste invite
F4 Rotate Onion locator
F5 Who Selected friend's profile
F6 Wallet Wallet screen
F8 RotatePrekey Prekey hard cut
F9 OpenMenu Wallets & settings

F9 is live on Main, the settings menu, and peer-payments so a printed shortcut never no-ops there. Other screens handle their own keys (Esc back, typed confirms).

Main

Focus starts on the composer. Footer hints (main_footer_hints):

Tab  F2  F3  F4  F5  F6  F9  ? help  Ctrl-Q

Pane-specific (pane_footer_hints):

Pane Hint
Roster j k select F3 add F6 wallet F9 settings ? help
Chat j k scroll g G ends F4 rotate F9 settings ? help
Composer Enter send / commands F9 settings ? help
Key Action
Tab / Shift-Tab Cycle roster → chat → composer
1 / 2 / 3 Focus roster / chat / composer when not typing
j k / arrows Move or scroll the focused pane
g / G Top / bottom of the focused pane
Enter Send chat, or run a /command
Esc Close overlay / clear composer
? Help (except on Paste, so ? can be in a payload)
Ctrl-Q Quit prompt

Composer commands

parse_cmd (src/tui.rs). Unknown /foo is sent as chat if it does not match.

Command Effect
/who Same as F5
/profile Profile editor
/pay <xmr> [memo] Invoice (inv ), one-shot
/tip <xmr> [memo] Transfer + rcp + tip , one-shot
/file /path File send, 1 MiB, one-shot
/wallet create Same as F6 then c
/wallet import Same as F6 then i
/settings Same as F9
/backup /path Encrypted identity export
/restore /path Overwrite self keys
/wipe Type WIPE — chat/payments/outbox; identity stays
/wipe-all Type WIPEALL — delete data dir; new person

Share / paste / rotate

  • F2. Full invite. C copies it (OSC 52). Esc back.
  • F3. Paste buffer, Enter submits. Unknown k → Approve (y/n). Same k updates locator and prekey only.
  • F4. Type ROTATE. Identity fingerprint unchanged. Online friends get loc ; offline friends must F3-paste the new invite.
  • F8. Type ROTATE. Prekey is the Noise static and the ratchet bootstrap seed. Every friend must F3-paste the new invite. Status: prekey rotated · friends must F3-paste your new invite.

Wallet (F6)

Footer:

c create  i import  v view-only  y copy  n send  r qr  w wallets  s/x child  1 pruned  2 full  3 testnet  Esc back  ? help
Key Effect
r or Enter Toggle receive-address QR
w Saved wallets (WalletSelect)
c Create wallet (SPEND then seed once, type SEEN)
i Import 25-word seed (then an optional seed-offset passphrase and restore height)
v Import an address to watch (address, view key twice, restore height, file passphrase)
y Copy the receive address (OSC 52). Never a seed, never a view key
n Send to a pasted address (address, amount, then SEND) — a local transfer, not a /tip
s Start app-owned wallet child
x Stop child (idempotent)
p Probe child (RPC answering? chain at tip?)
1 In-process Cuprate mainnet pruned (unvalidated)
2 In-process Cuprate mainnet full (unvalidated)
3 In-process Cuprate testnet
Esc Back to Main

The chain line for an in-process source always carries testnet only — mainnet is unvalidated (cuprate::TESTNET_ONLY). Starting Cuprate needs --features cuprate-daemon; without it, start fails with that feature name.

F6 shows one balance line — balance 0.9 XMR · unlocked 0.45 XMR, the total and the part a spend can use out of a single get_balance (wallet off when no wallet RPC is configured, balance — when the RPC did not answer with a total).

Create/import require the wallet RPC started with --wallet-dir. Filename: onionwire. Seed is never collected on the composer, and never copied.

The import's two optional steps have their own footers: the offset step says blank Enter skips Esc cancel ? help, the restore-height step says blank Enter scans from 0 Esc cancel ? help (blank means "scan from 0"; a height after your first receive hides the older funds and this version has no rescan). The send confirmation says type SEND Esc cancel ? help, and Esc there spends nothing. The view-only import has no seed, so it has no SEEN step.

Saved wallets (F6 then w)

WalletSelect. One row per persisted wallet — name, identity prefix, locator prefix, creation day — plus the selected row's full identity and locator under the table. j/k or arrows select, Enter opens the selection, Esc back to Main. Footer: Esc back j k select Enter open ? help.

The last item is not a wallet: + create new wallet starts the same create flow as F6 c, so an empty list still has a way forward. An unlabelled wallet (NULL in the store) reads (unlabelled); a wallet whose onion service is not published yet reads -; an unknown creation time reads unknown. A read that failed is named on the screen — that is a different state from no saved wallets yet, and the two never share copy.

Rows are plain display data (WalletRow), built by the caller from Node::list_wallets; the render path never reads the store. Selection is by row index, not by identity key (two records may share one).

The list is read when the screen opens — from the start screen and from F6 w — so a wallet created or imported in this session is offered the next time the screen opens, with no restart. Enter on a wallet row re-points the app-owned wallet child at that row's wallet_filename (Node::open_wallet, a read-modify-write of the sealed record, so the generated RPC creds survive); a running child is restarted onto the new file, and an idle one picks the change up on its next start.

Start screen. An install with at least one saved wallet opens on WalletSelect; a fresh install (empty catalogue) opens on the create flow (WalletSetup::CreateWarn), so the first run has no dead empty list. The stored identity and locator are catalogue columns, not session state: a locator rotates (F4) and identity is the roster key the node already holds, so the live header keeps reading them from the node.

Wallets & settings (F9 / /settings)

Discovery layer, not a replacement. Function keys stay live on this screen. Rows name the shortcut they sit beside (F6 c, F6 i, F6 r, F6 s/x, F6 p, /profile, /backup, /wipe, …).

  • No credentials on this screen. Login, seed, and passphrase are never passed into the menu snapshot.
  • c copies the receive address (OSC 52).
  • p opens peer payment history for the selected friend (Node::list_payments).
  • Esc back to Main.

The menu shows endpoint state; it does not edit a stored RPC URL. The error copy for an unconfigured wallet still says “open F7” (src/wallet.rs); that key does not exist. Set ONIONWIRE_WALLET_RPC or use F6 create/import and the child.

Chain source (binaries, remote host) is stored via Node::set_wallet_child_config. The desktop TUI's in-process picker is F6 keys 1/2/3. There is no on-screen editor for an external RPC URL or a remote daemon host.

Peer payments (F9 then p)

Peer-scoped signed invoices and tips, not the wallet's own transfer list. j/k or arrows select. Esc back. Footer: Esc back up/down select F9 menu ? help.

Delivery markers (chat)

Row state Marker
delivered ✓
queued ◷ queued (try n/8, retry …)
sending » sending
failed ✗ failed: …
inbound no marker

Footer {n} queued while anything is outstanding. File transfer and payments have no queue — outcome is a status note (invoice sent, tip sent, send failed: …).

Size

Floor 80×24. Target 120×40. Frame dumps:

cargo test --locked --test tui_spec -- --nocapture dump_spec_frames
cargo test --locked --test tui_spec -- --nocapture wallets_settings_menu_frame_dumps
cargo test --locked --test tui_select -- --nocapture wallet_select_frame_dumps