store: widen payments.kind to accept 'tip' (tips were never stored) #102

Merged
sirius merged 1 commit from wt/t_ecf204ad into main 2026-09-18 01:53:27 +00:00
Owner

Why

insert_payment has accepted kind = "tip" since the tip path landed, but the payments table's CHECK only allowed invoice/receipt. Every tip insert therefore failed with:

CHECK constraint failed: kind IN ('invoice','receipt')

That is not only the outbound card: the inbound path was broken too. Node::ingest_tip writes kind = "tip" first and returns on the error, so a received tip produced no payment row and no [tip] chat line, silently.

What changed

  • src/store.rs: new stores get CHECK(kind IN ('invoice','receipt','tip')); stores written before this change are rebuilt on open by widen_payment_kinds (SQLite cannot drop a CHECK), copying every row verbatim — ids, values and created_at included.
  • src/node.rs: outbound tip() records kind = "tip" with the tip's memo, matching ingest_tip; the _memo parameter is now used, so it is named memo. The [tip] chat line itself landed earlier in #96.

Tests (TDD, RED first)

test before after
node::tests::outbound_tip_records_a_tip_payment_row left: "receipt", right: "tip" pass
node::tests::an_inbound_tip_is_recorded_and_shown inbound tip must be stored: CHECK constraint failed pass
store::at_rest::a_store_predating_tip_payments_is_widened_on_open n/a (new) pass

Verification

  • cargo test --locked → exit 0, 294 passed / 0 failed / 4 ignored (was 291)
  • cargo clippy --locked --all-targets -- -D warnings → exit 0
  • rustfmt --edition 2024 --check src/{node,store}.rs → 7/8 hunks, identical to main (all inherited, none added)

Scope note

The card that requested this allowed only src/node.rs + tests/wallet.rs, and asked for the test in tests/wallet.rs. Both were impossible: Node::start is the only public constructor and it bootstraps Tor, so a Node cannot be built from tests/*.rs; and the requested kind = "tip" row cannot be written at all without the src/store.rs schema change. The tests therefore live in the existing #[cfg(test)] mod tests in src/node.rs, next to the harness the wallet cards already use.

## Why `insert_payment` has accepted `kind = "tip"` since the tip path landed, but the `payments` table's CHECK only allowed `invoice`/`receipt`. Every tip insert therefore failed with: ``` CHECK constraint failed: kind IN ('invoice','receipt') ``` That is not only the outbound card: the **inbound** path was broken too. `Node::ingest_tip` writes `kind = "tip"` first and returns on the error, so a received tip produced no payment row **and** no `[tip]` chat line, silently. ## What changed - `src/store.rs`: new stores get `CHECK(kind IN ('invoice','receipt','tip'))`; stores written before this change are rebuilt on open by `widen_payment_kinds` (SQLite cannot drop a CHECK), copying every row verbatim — ids, values and `created_at` included. - `src/node.rs`: outbound `tip()` records `kind = "tip"` with the tip's memo, matching `ingest_tip`; the `_memo` parameter is now used, so it is named `memo`. The `[tip]` chat line itself landed earlier in #96. ## Tests (TDD, RED first) | test | before | after | |---|---|---| | `node::tests::outbound_tip_records_a_tip_payment_row` | `left: "receipt", right: "tip"` | pass | | `node::tests::an_inbound_tip_is_recorded_and_shown` | `inbound tip must be stored: CHECK constraint failed` | pass | | `store::at_rest::a_store_predating_tip_payments_is_widened_on_open` | n/a (new) | pass | ## Verification - `cargo test --locked` → exit 0, **294 passed / 0 failed / 4 ignored** (was 291) - `cargo clippy --locked --all-targets -- -D warnings` → exit 0 - `rustfmt --edition 2024 --check src/{node,store}.rs` → 7/8 hunks, identical to `main` (all inherited, none added) ## Scope note The card that requested this allowed only `src/node.rs` + `tests/wallet.rs`, and asked for the test in `tests/wallet.rs`. Both were impossible: `Node::start` is the only public constructor and it bootstraps Tor, so a `Node` cannot be built from `tests/*.rs`; and the requested `kind = "tip"` row cannot be written at all without the `src/store.rs` schema change. The tests therefore live in the existing `#[cfg(test)] mod tests` in `src/node.rs`, next to the harness the wallet cards already use.
store: widen payments.kind to accept 'tip' so tips are stored
All checks were successful
ci / test (pull_request) Successful in 5m4s
ci / sdk (pull_request) Successful in 1m11s
android-ci / android (pull_request) Successful in 8m52s
05d7ada449
insert_payment has allowed kind = "tip" since the tip path landed, but the
payments table's CHECK only permitted invoice/receipt, so every tip insert
failed ("CHECK constraint failed: kind IN ('invoice','receipt')"). That made
the outbound tip row impossible and silently broke the inbound path too:
ingest_tip returned early and neither the row nor the [tip] chat line was
written.

- recreate the table with the widened CHECK on open, copying rows verbatim
  (new stores get it from the schema directly)
- outbound tip() records kind = "tip" with the tip's memo, matching ingest_tip
- tests: outbound row, inbound round trip, pre-tip store migration

Refs kanban t_ecf204ad
sirius force-pushed wt/t_ecf204ad from 05d7ada449
All checks were successful
ci / test (pull_request) Successful in 5m4s
ci / sdk (pull_request) Successful in 1m11s
android-ci / android (pull_request) Successful in 8m52s
to 67fb572962
Some checks failed
android-ci / android (pull_request) Successful in 9m49s
ci / test (pull_request) Successful in 5m2s
ci / sdk (pull_request) Successful in 1m10s
ci / fuzz (pull_request) Failing after 1m9s
2026-09-18 01:44:57 +00:00
Compare
sirius force-pushed wt/t_ecf204ad from 67fb572962
Some checks failed
android-ci / android (pull_request) Successful in 9m49s
ci / test (pull_request) Successful in 5m2s
ci / sdk (pull_request) Successful in 1m10s
ci / fuzz (pull_request) Failing after 1m9s
to 186ec7436d
Some checks failed
android-ci / android (pull_request) Successful in 8m6s
ci / test (pull_request) Successful in 4m43s
ci / sdk (pull_request) Successful in 57s
ci / fuzz (pull_request) Failing after 31s
2026-09-18 01:45:16 +00:00
Compare
sirius merged commit 2b7a306d43 into main 2026-09-18 01:53:27 +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!102
No description provided.