Skip to content

01a051eb - Persist forum invoice attempts and zap ingest decisions - #68

Merged
TaprootFreak merged 13 commits into
developfrom
01a051eb-persist-forum-invoices
Aug 30, 2026
Merged

01a051eb - Persist forum invoice attempts and zap ingest decisions#68
TaprootFreak merged 13 commits into
developfrom
01a051eb-persist-forum-invoices

Conversation

@TaprootFreakAI

Copy link
Copy Markdown
Collaborator

EN:
Forum payment attempts and kind:9735 ingest decisions are stored in Postgres so operators can debug zap invoices without screenshots. Each invoice row keeps the BOLT11, description versus description_hash, and whether it is a NIP-57 hash invoice. Rejected zap receipts are stored with a reason, not only logged. Debug listing is behind DEBUG_TOKEN.

DE:
Forum-Zahlungsversuche und kind:9735-Ingest-Entscheidungen liegen in Postgres, damit sich Zap-Invoices ohne Screenshots debuggen lassen. Jede Invoice-Zeile hält Bolt11, description gegen description_hash und ob es eine NIP-57-Hash-Invoice ist. Abgelehnte Zap-Receipts werden mit Grund gespeichert, nicht nur geloggt. Die Debug-Liste hängt an DEBUG_TOKEN.

Details

Problem: POST /messages/:id/invoice returned a BOLT11 and discarded it. A Wallet of Satoshi fallback invoice (plaintext 9734 JSON in description instead of description_hash) could be paid without ever creating a zap receipt, and the database had no copy of the invoice.

This change:

  • Adds message_invoice (every attempt after auth: ok, noZap, unreachable, no_event, and other results).
  • Adds nostr_zap_ingest (indexed or rejected, with reason).
  • Inspects BOLT11 via inspectBolt11 / isNip57Invoice without changing decodeBolt11.
  • Persist failures log and do not fail the HTTP payment.
  • GET /debug/invoices and GET /debug/zap-ingests (DEBUG_TOKEN).

No nsec is stored.

POST /messages/:id/invoice now writes every attempt (success and failure)
to message_invoice, including the BOLT11, description vs description_hash,
and whether the invoice is a NIP-57 hash invoice. kind:9735 ingest
records indexed and rejected outcomes in nostr_zap_ingest. Operators can
list both via DEBUG_TOKEN GET /debug/invoices and GET /debug/zap-ingests.
Handbook bullets for migrateMessageSchema and InMemoryMessageStore now
name message_invoice, nostr_zap_ingest, and the matching store methods.
CI lint failed prettier --check on three files; this matches the repo style.
Adds tests for null/array JSON mapping, sign_failed invoice rows, a
non-object signed zap request, and ingest errors without a string pubkey
so coverage meets the 100% gate.
Adds GET /debug/invoices and GET /debug/zap-ingests to the route table
and contracts, and names the new tables in the CONTRIBUTING schema tree.
POST /messages/:id/invoice now uses the same uuid check as photo fetch, so
Postgres is not asked to cast garbage into message_invoice.message_id.
Invoice tests with a non-integer sats body now use a uuid path so the
new invoice id check does not turn them into 404.
POST /messages/:id/invoice now states the UUID guard, best-effort
message_invoice rows, and the full result union on GET /debug/invoices.
GitHub did not start check-runs on the previous two commits.
@TaprootFreakAI
TaprootFreakAI force-pushed the 01a051eb-persist-forum-invoices branch from eab875c to d09c919 Compare August 30, 2026 12:53
After the NIP-65 rebase, MessageStore includes listSignedMissingPhoto and
resetSignedEvent; the invoice/ingest test doubles now implement them.
Ignores zod/cap and missing-key persist that sit behind existing v8
guards, records a null zap_request bind, and marks the catch-path
pubkey ternary as unreachable after the ingest guard.
The ok persist path records paymentHash and descriptionHash when the
BOLT11 inspects, covering the non-null optional-chaining branches.
@TaprootFreakAI

Copy link
Copy Markdown
Collaborator Author

EN:
Ready after 1 review pass.
Forum invoice attempts and zap ingest decisions are stored in Postgres and listed under DEBUG_TOKEN.

DE:
Bereit nach 1 Review-Durchlauf.
Forum-Invoice-Versuche und Zap-Ingest-Entscheidungen liegen in Postgres und unter DEBUG_TOKEN.

Details

Rebased onto develop after #66 (NIP-65/picture/imeta). Combined store handbook bullets. Grok quality and logic: 0 findings. CI green on 6850dd3. Mergeable CLEAN. PR #69 closed as superseded by #66. Operator: Codex follow-ups, if any, land in a later PR.

@TaprootFreakAI
TaprootFreakAI marked this pull request as ready for review August 30, 2026 13:12
@TaprootFreak
TaprootFreak merged commit 4ea6037 into develop Aug 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants