node: expose peer payment history (Node::list_payments) #119

Merged
sirius merged 1 commit from onionwire/t_21787cec-node-expose-peer-payment-history-node-li into main 2026-09-19 04:09:05 +00:00
Owner

Closes the one capability card t_8bb1bac9 found unreachable: peer payment history.

Store::list_payments (src/store.rs:953) was called only from src/node.rs's own tests. There was no accessor, so the TUI's payment view could only show the wallet's own transfer list; the signed /pay invoices and /tip receipts a peer sent were invisible.

API for the TUI card

src/node.rs:512
pub fn list_payments(&self, friend_pk: &[u8]) -> Result<Vec<Payment>, String>
  • Payment is store::Payment (src/store.rs:94), re-exported nowhere else; the TUI already reaches store types through node's public API the same way list_messages -> Message does.
  • Rows are ordered by payments.id ascending (oldest first) and carry id, dir, kind, amount_atomic, address, memo, txid, verified, created_at.
  • A friend with no payment rows is Ok(vec![]), not an error.
  • Read-only and fail-closed: it takes the store lock and nothing else. No Tor dial, no wallet RPC, no new state, no schema or wire change.
  • Payment's shape is untouched. memo is peer-signed text stored as it arrived; the renderer sanitizes it with sanitize::display_text at draw time, exactly as it already does for Message::plaintext in src/tui.rs:313. The accessor adds no second display path.

Tests

cargo test --locked — all targets green, 0 failed. New test node::tests::list_payments_round_trips_a_peers_invoice_and_receipt (RED first: E0599 no method named list_payments found for struct node::Node, naming both call sites) stores an inbound invoice and an inbound receipt through Store::insert_payment, then asserts the accessor returns both in id order with the stored fields, and that a befriend'd friend with no rows yields an empty vector.

cargo clippy --locked --all-targets -- -D warnings — clean.

rustfmt --edition 2024 --check src/node.rs — 0 diffs, same as git show HEAD:src/node.rs (no inherited churn, none introduced).

Only src/node.rs changed (+82/-1): the accessor, the Payment import, and the test. Built with CARGO_TARGET_DIR=/var/tmp/onionwire-tui-target (warm) and TMPDIR=/var/tmp/onionwire-tui-tmp.

Closes the one capability card t_8bb1bac9 found unreachable: **peer payment history**. `Store::list_payments` (`src/store.rs:953`) was called only from `src/node.rs`'s own tests. There was no accessor, so the TUI's payment view could only show the wallet's own transfer list; the signed `/pay` invoices and `/tip` receipts a peer sent were invisible. ## API for the TUI card ``` src/node.rs:512 pub fn list_payments(&self, friend_pk: &[u8]) -> Result<Vec<Payment>, String> ``` - `Payment` is `store::Payment` (`src/store.rs:94`), re-exported nowhere else; the TUI already reaches `store` types through `node`'s public API the same way `list_messages` -> `Message` does. - Rows are ordered by `payments.id` ascending (oldest first) and carry `id, dir, kind, amount_atomic, address, memo, txid, verified, created_at`. - A friend with no payment rows is `Ok(vec![])`, not an error. - Read-only and fail-closed: it takes the store lock and nothing else. No Tor dial, no wallet RPC, no new state, no schema or wire change. - `Payment`'s shape is untouched. `memo` is peer-signed text stored as it arrived; the renderer sanitizes it with `sanitize::display_text` at draw time, exactly as it already does for `Message::plaintext` in `src/tui.rs:313`. The accessor adds no second display path. ## Tests `cargo test --locked` — all targets green, 0 failed. New test `node::tests::list_payments_round_trips_a_peers_invoice_and_receipt` (RED first: `E0599 no method named list_payments found for struct node::Node`, naming both call sites) stores an inbound invoice and an inbound receipt through `Store::insert_payment`, then asserts the accessor returns both in id order with the stored fields, and that a befriend'd friend with no rows yields an empty vector. `cargo clippy --locked --all-targets -- -D warnings` — clean. `rustfmt --edition 2024 --check src/node.rs` — 0 diffs, same as `git show HEAD:src/node.rs` (no inherited churn, none introduced). Only `src/node.rs` changed (+82/-1): the accessor, the `Payment` import, and the test. Built with `CARGO_TARGET_DIR=/var/tmp/onionwire-tui-target` (warm) and `TMPDIR=/var/tmp/onionwire-tui-tmp`.
node: expose peer payment history as Node::list_payments
Some checks failed
ci / test (pull_request) Successful in 8m27s
ci / sdk (pull_request) Successful in 1m29s
ci / fuzz (pull_request) Failing after 16m49s
android-ci / android (pull_request) Successful in 10m52s
86e20223cf
Store::list_payments existed but only the node's own tests called it, so the
signed /pay invoices and /tip receipts a peer sent were unreachable from the
app. Add the thinnest read-only accessor next to list_messages/friend_profile:
lock the store, map the error to String, no new state, no new schema, no dial.

Payment rows come back as stored; a renderer sanitizes memo with
sanitize::display_text at draw time, the same way it does for message bodies.
sirius merged commit b46d858a4d into main 2026-09-19 04:09:05 +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!119
No description provided.