wallet: unlocked balance, restore height, outgoing rows, send, view-only import #158

Owner

Stacked on onionwire/t_dc9b74a6-onionwire-wallet-optional-seed-offset-pa (PR #156), per the card: the parent branch is still one commit ahead of main, so base is that branch, not main.

What lands

Unlocked balance. get_balance answers with a total and an unlocked half; the screen only showed the total. Node::wallet_balance_line now reads both out of one answer — balance {total} XMR · unlocked {unlocked} XMR, the balance 0 XMR prefix kept when the total is 0, and the old total-only line when the RPC reports no unlocked half. Node::wallet_unlocked_balance and the SDK's wallet_unlocked_balance() report the unlocked half alone with wallet_balance's own off / err sentinels. wallet_balance() is unchanged (its shape, and its off / err sentinels that the WALLETS & SETTINGS menu tones read, are untouched).

Outgoing rows. get_transfers now sends out: true and parses the out bucket; TransferRow (core and the UniFFI record) gains direction, which is the bucket name — a pending item's own string type wins when it has one. Two buckets with the same txid are both kept.

Restore height. Wallet::restore_wallet / Node::wallet_restore take restore_height: Option<u64> beside the parent's seed_offset. Blank omits the JSON field entirely, a typed 0 is sent as 0, Some(n) is a JSON number, and a non-numeric height is the local refusal restore height must be a block number with no dial. TUI: a restore height step between the offset and the file passphrase, digits only, footer blank Enter scans from 0 Esc cancel ? help (deliberately not the offset screen's blocked footer), and Esc wipes the seed and the offset. SDK: import_seed(password, seed, offset, height) — the 4-arg call the phone will make; import_wallet and the parent's 3-arg import_wallet_with_offset keep their signatures.

Send to a pasted address. Node::wallet_send(address, amount_xmr) is check_address → xmr_to_atomic → Wallet::transfer, and nothing else: no friend, no tip frame, no chat line, no payment-table row. Empty fields are local refusals with no dial; a bad address is check_address's own invalid Monero address; a view-only or unsynced refusal is the string transfer already returns. TUI: n on the wallet screen — address, amount, then SEND (case-insensitive) before the call; Esc spends nothing; footer type SEND Esc cancel ? help; success puts the txid in the status note. SDK: wallet_send(address, amount_xmr).

Copy the receive address. y reuses osc52_copy_sequence on wallet_receive_address, status copied address (or the existing clipboard-failure string). No receive address uses the existing no receive address — set profile xmr or ONIONWIRE_WALLET_RPC. The seed is never copied; neither is a view key.

View-only import. Wallet::import_view_only / Node::wallet_import_view_only call generate_from_keys with the address, the view key and no spendkey field at all; same filename/password refusals as restore_wallet, check_address before the dial, a 64-hex view key or the local refusal view key must be 64 hex characters, optional height omitted when blank. The node path is wallet_restore's: next_wallet_filename, RPC, record_wallet, point_child_at, seal_wallet_passphrase (the file passphrase only), mark_child_wallet_open, and the view key is zeroized after the call — no catalogue column, no seal, no log, no argv. TUI: v → address (visible) → view key hidden, typed twice (view keys do not match, no RPC) → restore height → file passphrase; Esc wipes the view key; no SEEN gate, because there is no seed. SDK: import_view_only(password, address, view_key, height) and wallet_view_only() (true only on the existing -29 view-only refusal; a spend key that comes back is discarded, never returned, never logged; not-configured is a WResult error, not true).

Footer / help line. 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 in src/tui.rs and docs/TUI.md, with every old token kept, and the matching wallet help line.

One F6 render fix. The wallet body was rendered into the fixed two-row slot of its layout, so the bordered block drew only its borders and clipped the address, the balance line and the transfers — on every terminal size, before this branch. It now renders in the flexible region. The frame test below asserts the balance line, the address label and recent transfers are all on the buffer.

Docs. docs/WALLET.md (total vs unlocked, restore height and the no-rescan warning, outgoing rows, local send, view-only import), docs/THREAT_MODEL.md (a view key entered at import is an incoming-visibility secret; a view-only file is not a spend authority; the file passphrase is still what is sealed), docs/TUI.md (footer, keys, the new steps), README.md (one sentence).

Not in this PR

No new crate, no Cargo.toml / lockfile change, no android/ change, no camera, no QR scan, no price ticker, no rescan_blockchain. The view key is not sealed; only the file passphrase is, exactly as before.

Verify

$ export TMPDIR=/home/lancelot/.hermes/tmp/wallet-section
$ cargo test --locked --target x86_64-unknown-linux-gnu
39 test binaries: all ok, 0 failed — lib 117, wallet 67, tui_spec 37, tui_frames 32,
two_node 18, store 18, payments 16, … (1m22s)
$ cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings
exit 0, no warnings

SDK (its own crate, own target dir under $TMPDIR):
$ CARGO_TARGET_DIR=$TMPDIR/sdk-target cargo test --locked --target x86_64-unknown-linux-gnu
57 + 1 + 1 passed, 0 failed
$ … cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings
exit 0, no warnings

New request-byte tests in tests/wallet.rs: a typed height is a JSON number and blank omits the key; generate_from_keys carries the view key and the address and contains no spendkey; the get_transfers request asks for out; wallet_send reaches transfer and never tip; a short/non-hex view key is a local error that does not dial. wallet_balance on a stopped handle still reads off.

tests/tui_spec.rs::alert_line_prefixes_when_no_color is order-dependent and pre-existing: it asserts on a process-global NO_COLOR that another test in the same binary mutates (tests/tui_spec.rs:689). It failed once in a full-suite run on this branch (and once before the render change), passes in isolation here (8/8) and on the base commit (6/6). Nothing in this diff touches NO_COLOR or alert_line.

Not verified against a live monero-wallet-rpc — none is on PATH, and the card says not to download one. The request bytes, the local refusals and the flows are what is proven here.

Stacked on `onionwire/t_dc9b74a6-onionwire-wallet-optional-seed-offset-pa` (PR #156), per the card: the parent branch is still one commit ahead of `main`, so `base` is that branch, not `main`. ## What lands **Unlocked balance.** `get_balance` answers with a total and an unlocked half; the screen only showed the total. `Node::wallet_balance_line` now reads both out of **one** answer — `balance {total} XMR · unlocked {unlocked} XMR`, the `balance 0 XMR` prefix kept when the total is 0, and the old total-only line when the RPC reports no unlocked half. `Node::wallet_unlocked_balance` and the SDK's `wallet_unlocked_balance()` report the unlocked half alone with `wallet_balance`'s own `off` / `err` sentinels. `wallet_balance()` is unchanged (its shape, and its `off` / `err` sentinels that the WALLETS & SETTINGS menu tones read, are untouched). **Outgoing rows.** `get_transfers` now sends `out: true` and parses the `out` bucket; `TransferRow` (core and the UniFFI record) gains `direction`, which is the bucket name — a pending item's own string `type` wins when it has one. Two buckets with the same txid are both kept. **Restore height.** `Wallet::restore_wallet` / `Node::wallet_restore` take `restore_height: Option<u64>` beside the parent's `seed_offset`. Blank omits the JSON field entirely, a typed `0` is sent as `0`, `Some(n)` is a JSON **number**, and a non-numeric height is the local refusal `restore height must be a block number` with no dial. TUI: a `restore height` step between the offset and the file passphrase, digits only, footer `blank Enter scans from 0 Esc cancel ? help` (deliberately not the offset screen's blocked footer), and Esc wipes the seed and the offset. SDK: `import_seed(password, seed, offset, height)` — the 4-arg call the phone will make; `import_wallet` and the parent's 3-arg `import_wallet_with_offset` keep their signatures. **Send to a pasted address.** `Node::wallet_send(address, amount_xmr)` is `check_address` → `xmr_to_atomic` → `Wallet::transfer`, and nothing else: no friend, no `tip` frame, no chat line, no payment-table row. Empty fields are local refusals with no dial; a bad address is `check_address`'s own `invalid Monero address`; a view-only or unsynced refusal is the string `transfer` already returns. TUI: `n` on the wallet screen — address, amount, then `SEND` (case-insensitive) before the call; Esc spends nothing; footer `type SEND Esc cancel ? help`; success puts the txid in the status note. SDK: `wallet_send(address, amount_xmr)`. **Copy the receive address.** `y` reuses `osc52_copy_sequence` on `wallet_receive_address`, status `copied address` (or the existing clipboard-failure string). No receive address uses the existing `no receive address — set profile xmr or ONIONWIRE_WALLET_RPC`. The seed is never copied; neither is a view key. **View-only import.** `Wallet::import_view_only` / `Node::wallet_import_view_only` call `generate_from_keys` with the address, the view key and **no `spendkey` field at all**; same filename/password refusals as `restore_wallet`, `check_address` before the dial, a 64-hex view key or the local refusal `view key must be 64 hex characters`, optional height omitted when blank. The node path is `wallet_restore`'s: `next_wallet_filename`, RPC, `record_wallet`, `point_child_at`, `seal_wallet_passphrase` (the file passphrase only), `mark_child_wallet_open`, and the view key is zeroized after the call — no catalogue column, no seal, no log, no argv. TUI: `v` → address (visible) → view key hidden, typed twice (`view keys do not match`, no RPC) → restore height → file passphrase; Esc wipes the view key; no `SEEN` gate, because there is no seed. SDK: `import_view_only(password, address, view_key, height)` and `wallet_view_only()` (true only on the existing `-29` view-only refusal; a spend key that comes back is discarded, never returned, never logged; not-configured is a `WResult` error, not `true`). **Footer / help line.** `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` in `src/tui.rs` and `docs/TUI.md`, with every old token kept, and the matching wallet help line. **One F6 render fix.** The wallet body was rendered into the fixed two-row slot of its layout, so the bordered block drew only its borders and clipped the address, the balance line and the transfers — on every terminal size, before this branch. It now renders in the flexible region. The frame test below asserts the balance line, the `address` label and `recent transfers` are all on the buffer. **Docs.** `docs/WALLET.md` (total vs unlocked, restore height and the no-rescan warning, outgoing rows, local send, view-only import), `docs/THREAT_MODEL.md` (a view key entered at import is an incoming-visibility secret; a view-only file is not a spend authority; the file passphrase is still what is sealed), `docs/TUI.md` (footer, keys, the new steps), `README.md` (one sentence). ## Not in this PR No new crate, no `Cargo.toml` / lockfile change, no `android/` change, no camera, no QR scan, no price ticker, no `rescan_blockchain`. The view key is not sealed; only the file passphrase is, exactly as before. ## Verify ``` $ export TMPDIR=/home/lancelot/.hermes/tmp/wallet-section $ cargo test --locked --target x86_64-unknown-linux-gnu 39 test binaries: all ok, 0 failed — lib 117, wallet 67, tui_spec 37, tui_frames 32, two_node 18, store 18, payments 16, … (1m22s) $ cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings exit 0, no warnings SDK (its own crate, own target dir under $TMPDIR): $ CARGO_TARGET_DIR=$TMPDIR/sdk-target cargo test --locked --target x86_64-unknown-linux-gnu 57 + 1 + 1 passed, 0 failed $ … cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings exit 0, no warnings ``` New request-byte tests in `tests/wallet.rs`: a typed height is a JSON number and blank omits the key; `generate_from_keys` carries the view key and the address and contains no `spendkey`; the `get_transfers` request asks for `out`; `wallet_send` reaches `transfer` and never `tip`; a short/non-hex view key is a local error that does not dial. `wallet_balance` on a stopped handle still reads `off`. `tests/tui_spec.rs::alert_line_prefixes_when_no_color` is order-dependent and pre-existing: it asserts on a process-global `NO_COLOR` that another test in the same binary mutates (`tests/tui_spec.rs:689`). It failed once in a full-suite run on this branch (and once before the render change), passes in isolation here (8/8) and on the base commit (6/6). Nothing in this diff touches `NO_COLOR` or `alert_line`. Not verified against a live `monero-wallet-rpc` — none is on `PATH`, and the card says not to download one. The request bytes, the local refusals and the flows are what is proven here.
wallet: unlocked balance, restore height, outgoing rows, send, view-only import
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
93deaa5309
`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.
Merge branch 'onionwire/t_dc9b74a6-onionwire-wallet-optional-seed-offset-pa' into onionwire/t_0329f5bf-onionwire-wallet-unlocked-balance-restor
Some checks failed
android-ci / android (pull_request) Has been cancelled
ci / test (pull_request) Successful in 6m38s
ci / sdk (pull_request) Successful in 1m35s
ci / fuzz (pull_request) Successful in 5m39s
097772dd11
sirius merged commit d362cde5c0 into onionwire/t_dc9b74a6-onionwire-wallet-optional-seed-offset-pa 2026-09-26 00:57:15 +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!158
No description provided.