tui: peer payment history behind the F9 payments row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and `/tip` receipts a peer sent live in the `payments` table and had no path from the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that gap; this wires it into a screen. - `Screen::PeerPayments { state }` + `PeerPaymentsState` / `PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from `Node::list_payments`' rows (newest first: the store returns `payments.id` ascending, the screen windows the vector). - Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down` (or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu. - Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same piconero formatter the chat lines use), memo (sanitized at draw time) and the receipt's `verified` / `unverified` word; the focused row is marked with `>` and bold. The selected row's txid and address sit under the rows — the address wrapped over two lines rather than clipped. - States: populated, `no payments with {peer}`, `could not read payments`, and a menu row that refuses when no friend is selected. An empty history is a state, never an error. - Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the new `payments` row (key `p`) names the peer and the count. Two histories, two rows, no ambiguity. - Widths are measured in cells (`Span::width`); trailing columns are dropped before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as 120x40 and 200x60. Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at 80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the window/column invariants for every width from 20 to 200. Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was asserted to start with `"abcdef"`, which only holds when another test's in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars without a global lock, so that test flaked (it also fails on an unmodified tree, 1 run in 2). It now accepts either chrome's cut point, which is what the comment already claimed. Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and the updated row count; the "peer payment history" gap entry is closed.
This commit is contained in:
parent
b1a6796742
commit
2fa3466019
4 changed files with 1095 additions and 26 deletions
84
docs/TUI.md
84
docs/TUI.md
|
|
@ -653,7 +653,8 @@ fires it, including the F6 wallet screen's own keys (`F6 c`, `F6 i`, `F6 r`,
|
|||
| WALLET | sync | chain readiness word (`chain at tip · wallet answering`, `wallet answering · chain not at tip`, `wallet RPC not answering yet`, `child exited`, `not probing · no chain source`) | `F6 p` |
|
||||
| WALLET | receive | the receive address (truncated) or `no address yet · wallet unreachable` | `c copy` / `F6 r` |
|
||||
| WALLET | balance | `{xmr}` / `off` / `err` | `F6` |
|
||||
| WALLET | payments | `{n} recent` / `no transfers yet` | `F6` |
|
||||
| WALLET | transfers | `{n} recent` / `no transfers yet` — the wallet's **own** transfer list | `F6` |
|
||||
| WALLET | payments | `{n} with {peer}` / `no history with {peer}` / `no friend selected` / `history unreadable · {peer}` — the **peer's** payment rows | `p` |
|
||||
| WALLET | create | `/wallet create · seed shown once` | `F6 c` |
|
||||
| WALLET | import | `/wallet import · 25-word seed` | `F6 i` |
|
||||
| SETTINGS | nickname | the self-profile name, or `(none)` | `/profile` |
|
||||
|
|
@ -665,7 +666,13 @@ fires it, including the F6 wallet screen's own keys (`F6 c`, `F6 i`, `F6 r`,
|
|||
| SETTINGS | wipe | `messages · identity and friends stay` | `/wipe` |
|
||||
| SETTINGS | wipe-all | `deletes your identity key · new person` | `/wipe-all` |
|
||||
|
||||
19 rows at 80x24 against 21 available inner rows: nothing clips or scrolls.
|
||||
20 rows at 80x24 against 21 available inner rows: nothing clips or scrolls.
|
||||
|
||||
`transfers` and `payments` are deliberately two rows: `transfers` is the
|
||||
wallet's own list (`Node::wallet_recent_transfers`, F6), `payments` is the
|
||||
peer-scoped history (`Node::list_payments`, `p`). Signed `/pay` invoices and
|
||||
`/tip` receipts a peer sent never appear in the wallet's own transfers, so the
|
||||
two histories are not interchangeable and the menu names both.
|
||||
|
||||
### Guarantees
|
||||
|
||||
|
|
@ -699,8 +706,77 @@ sibling-card work, not presentation:
|
|||
`Node::wallet_test_connection(..)` — the endpoint config screen is F7 on
|
||||
`feat/wallet-create-import`; the menu shows the endpoint's *state* and leaves
|
||||
the key free.
|
||||
- Peer payment history — `store.list_payments(..)` has no `Node` accessor, so
|
||||
the menu can only offer the wallet's own transfer list (F6).
|
||||
- Peer payment history — **closed by this screen.** `Node::list_payments` exists
|
||||
on `main`; the `payments` row (key `p`) opens the peer-scoped history, and the
|
||||
row is distinct from the wallet's own transfer list (`transfers`, F6).
|
||||
- `Node::set_wallet_child_config(cfg)` — the child can be started/stopped and
|
||||
probed, not edited.
|
||||
- `Node::set_petname(..)` — no petname editor exists.
|
||||
|
||||
## Peer payment history (F9 → `payments`, key `p`)
|
||||
|
||||
A screen, not a popup, and peer-scoped: it renders what
|
||||
`Node::list_payments(&friend_pk)` returns for the chat's selected friend, so the
|
||||
signed `/pay` invoices and `/tip` receipts a peer sent are visible even though
|
||||
they never appear in the wallet's own transfer list (F6). The call takes the
|
||||
store lock only — no Tor dial, no wallet RPC — so it is safe while offline or
|
||||
while Arti is still bootstrapping, and an empty result (`Ok(vec![])`) is the
|
||||
**no history** state, never an error.
|
||||
|
||||
```
|
||||
cargo test --locked --test tui_payments -- --nocapture peer_payments_frame_dumps
|
||||
```
|
||||
|
||||
dumps the screen at 80x24, 120x40 and 200x60, populated and empty.
|
||||
|
||||
### Layout
|
||||
|
||||
```
|
||||
dir kind amount XMR receipt memo
|
||||
> in receipt 0.025 verified lunch money
|
||||
out tip 0.005 coffee
|
||||
out invoice 0.1 rent
|
||||
|
||||
tx 3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041
|
||||
addr 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMW
|
||||
aC8iqPUE9XUBFGrLyDz4DpEBM
|
||||
```
|
||||
|
||||
- Rows are **newest first**: `payments.id` ascending is oldest first, so
|
||||
`PeerPaymentsState::from_payments` reverses it and the render path windows the
|
||||
result. Rows outside the window are counted in an explicit `… N older` /
|
||||
`… N newer` line — nothing is dropped silently.
|
||||
- The focused row is marked with `>` **and** bold, so focus survives a
|
||||
monochrome terminal. `up`/`down` (or `k`/`j`) move it, `Esc` returns to the
|
||||
main screen, `F9` reopens the menu.
|
||||
- The selected row's `tx` and `addr` are spelled out under the rows: a 64-hex
|
||||
txid is unusable truncated, and a 95-character base58 address is **wrapped**
|
||||
over two lines rather than clipped to a prefix.
|
||||
- Amounts use `pay::atomic_to_xmr_str`, the same piconero formatter the chat
|
||||
lines use; the XMR unit is stated once, in the column header.
|
||||
- Columns are dropped from the right when the pane is narrower than they need,
|
||||
so no row can wrap or overrun at any width — not just at 80.
|
||||
|
||||
### States
|
||||
|
||||
| State | Frame |
|
||||
|---|---|
|
||||
| populated | the rows, plus the selected row's `tx` / `addr` |
|
||||
| empty | `no payments with {peer}` and `invoices, receipts and tips from this peer land here` |
|
||||
| read failed | `could not read payments` plus the sanitized reason — never a blank pane |
|
||||
| no friend selected | the menu row refuses before the screen opens (`no friend selected` in the status line) |
|
||||
|
||||
### Guarantees
|
||||
|
||||
- **Memo is peer-signed text, sanitized at draw time.** `Node::list_payments`
|
||||
returns `memo` as stored; the row goes through the same
|
||||
`menu_cell_text`-then-`fit_cells` path the F9 menu uses, so C0/C1 controls,
|
||||
ESC, bidi marks and newlines cannot reach the frame buffer or split a row.
|
||||
`tests/tui_payments.rs` asserts a hostile memo (ESC, BEL, C1, bidi, newline)
|
||||
never appears in a rendered frame.
|
||||
- **Only receipts carry `verified`.** The flag column prints `verified` /
|
||||
`unverified` for receipts and stays blank for invoices and tips, which have no
|
||||
signature to check; `unverified` also takes the warn tone, so colour is never
|
||||
the only signal.
|
||||
- **Read-only.** The screen reads one getter and draws; it cannot send, sign or
|
||||
dial.
|
||||
|
|
|
|||
Loading…
Reference in a new issue