wallet: unlocked balance, restore height, outgoing rows, send, view-only import #158
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_0329f5bf-onionwire-wallet-unlocked-balance-restor"
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?
Stacked on
onionwire/t_dc9b74a6-onionwire-wallet-optional-seed-offset-pa(PR #156), per the card: the parent branch is still one commit ahead ofmain, sobaseis that branch, notmain.What lands
Unlocked balance.
get_balanceanswers with a total and an unlocked half; the screen only showed the total.Node::wallet_balance_linenow reads both out of one answer —balance {total} XMR · unlocked {unlocked} XMR, thebalance 0 XMRprefix kept when the total is 0, and the old total-only line when the RPC reports no unlocked half.Node::wallet_unlocked_balanceand the SDK'swallet_unlocked_balance()report the unlocked half alone withwallet_balance's ownoff/errsentinels.wallet_balance()is unchanged (its shape, and itsoff/errsentinels that the WALLETS & SETTINGS menu tones read, are untouched).Outgoing rows.
get_transfersnow sendsout: trueand parses theoutbucket;TransferRow(core and the UniFFI record) gainsdirection, which is the bucket name — a pending item's own stringtypewins when it has one. Two buckets with the same txid are both kept.Restore height.
Wallet::restore_wallet/Node::wallet_restoretakerestore_height: Option<u64>beside the parent'sseed_offset. Blank omits the JSON field entirely, a typed0is sent as0,Some(n)is a JSON number, and a non-numeric height is the local refusalrestore height must be a block numberwith no dial. TUI: arestore heightstep between the offset and the file passphrase, digits only, footerblank 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_walletand the parent's 3-argimport_wallet_with_offsetkeep their signatures.Send to a pasted address.
Node::wallet_send(address, amount_xmr)ischeck_address→xmr_to_atomic→Wallet::transfer, and nothing else: no friend, notipframe, no chat line, no payment-table row. Empty fields are local refusals with no dial; a bad address ischeck_address's owninvalid Monero address; a view-only or unsynced refusal is the stringtransferalready returns. TUI:non the wallet screen — address, amount, thenSEND(case-insensitive) before the call; Esc spends nothing; footertype SEND Esc cancel ? help; success puts the txid in the status note. SDK:wallet_send(address, amount_xmr).Copy the receive address.
yreusesosc52_copy_sequenceonwallet_receive_address, statuscopied address(or the existing clipboard-failure string). No receive address uses the existingno 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_onlycallgenerate_from_keyswith the address, the view key and nospendkeyfield at all; same filename/password refusals asrestore_wallet,check_addressbefore the dial, a 64-hex view key or the local refusalview key must be 64 hex characters, optional height omitted when blank. The node path iswallet_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; noSEENgate, because there is no seed. SDK:import_view_only(password, address, view_key, height)andwallet_view_only()(true only on the existing-29view-only refusal; a spend key that comes back is discarded, never returned, never logged; not-configured is aWResulterror, nottrue).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 ? helpinsrc/tui.rsanddocs/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
addresslabel andrecent transfersare 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, noandroid/change, no camera, no QR scan, no price ticker, norescan_blockchain. The view key is not sealed; only the file passphrase is, exactly as before.Verify
New request-byte tests in
tests/wallet.rs: a typed height is a JSON number and blank omits the key;generate_from_keyscarries the view key and the address and contains nospendkey; theget_transfersrequest asks forout;wallet_sendreachestransferand nevertip; a short/non-hex view key is a local error that does not dial.wallet_balanceon a stopped handle still readsoff.tests/tui_spec.rs::alert_line_prefixes_when_no_coloris order-dependent and pre-existing: it asserts on a process-globalNO_COLORthat 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 touchesNO_COLORoralert_line.Not verified against a live
monero-wallet-rpc— none is onPATH, and the card says not to download one. The request bytes, the local refusals and the flows are what is proven here.`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.