Skip to content

01a051eb - Reject non-NIP-57 forum invoices before showing a QR - #76

Merged
TaprootFreak merged 3 commits into
developfrom
01a051eb-reject-non-zap-invoice
Aug 30, 2026
Merged

01a051eb - Reject non-NIP-57 forum invoices before showing a QR#76
TaprootFreak merged 3 commits into
developfrom
01a051eb-reject-non-zap-invoice

Conversation

@TaprootFreakAI

Copy link
Copy Markdown
Collaborator

EN:
Forum pay now returns a Lightning invoice only when it is a NIP-57 zap invoice (description_hash of the kind:9734 request). A Wallet of Satoshi-style plaintext invoice is stored as not_zap for operators and rejected with 400, so the app never shows a QR for a payment the forum cannot credit. Sats still increment only on a validated kind:9735 receipt.

DE:
Die Forum-Zahlung gibt eine Lightning-Rechnung nur noch aus, wenn sie eine NIP-57-Zap-Rechnung ist (description_hash der kind:9734-Anfrage). Eine Klartext-Rechnung wie bei Wallet of Satoshi wird als not_zap gespeichert und mit 400 abgelehnt, damit die App keinen QR für eine Zahlung zeigt, die das Forum nicht gutschreiben kann. Sats steigen weiterhin nur durch eine geprüfte kind:9735-Quittung.

Details

Problem: POST /messages/:id/invoice returned any LNURL-pay BOLT11 after a successful zap fetch. Some wallets (notably Wallet of Satoshi) mint a plaintext-description invoice even when allowsNostr is true. Paying that invoice does not produce a NIP-57 kind:9735 receipt, so the forum never credits sats while the payer's funds are gone.

Change: after requestZapInvoice succeeds, inspect the BOLT11 and call isNip57Invoice once. Return { pr, amountSats } only when the invoice description_hash equals SHA-256 of the zap-request JSON. Otherwise persist result: 'not_zap' with the rejected pr (debug listing), HTTP 400 { "error": "Could not start the Bitcoin payment" }, and no pr in the body. noZap (LNURL without Nostr) stays a separate result.

Tests spy isNip57Invoice true on existing HTTP 200 invoice paths (fake lnbc21n1test is not a real NIP-57 invoice) and add a Wallet of Satoshi plaintext case that must 400 / not_zap. SPEC and handbook updated. No SQL change (message_invoice.result is text).

POST /messages/:id/invoice now returns { pr, amountSats } only when the
minted BOLT11 description_hash matches the zap request. Plaintext LN
invoices are persisted as not_zap for debug and rejected with 400 so
the client never shows a QR that cannot produce a kind:9735 receipt.
The ok persist path stores a literal true after the gate, so the
handbook Used-by line must not claim a second call.
@TaprootFreakAI
TaprootFreakAI force-pushed the 01a051eb-reject-non-zap-invoice branch from 9266ab0 to 4c1d78c Compare August 30, 2026 14:48
The 100% branch gate failed on inspected?.paymentHash when inspectBolt11
returns null (malformed LNURL invoice). Persist still stores the pr.
@TaprootFreakAI

Copy link
Copy Markdown
Collaborator Author

EN:
Ready after 2 review passes.
Forum pay returns a Lightning invoice only when it is a NIP-57 zap invoice, so a QR cannot be shown for a payment the forum cannot credit.

DE:
Bereit nach 2 Review-Durchläufen.
Die Forum-Zahlung gibt eine Lightning-Rechnung nur noch aus, wenn sie eine NIP-57-Zap-Rechnung ist, damit kein QR für eine Zahlung erscheint, die das Forum nicht gutschreiben kann.

Details

Review: two quality+logic passes on the invoice-gate diff (first quality pass: handbook Used-by claimed a second isNip57Invoice call; fixed in the follow-up commit). Rebase onto develop after Web Push (#67) resolved a handbook messagesRoutes conflict by keeping both the NIP-57 gate and pushStore. CI on fac225e is green (typecheck, lint, handbook, e2e-check, 100% coverage, build, e2e). mergeable: MERGEABLE. No open review threads. Commits are GitHub-verified.

@TaprootFreakAI
TaprootFreakAI marked this pull request as ready for review August 30, 2026 14:52
@TaprootFreak
TaprootFreak merged commit 1526a44 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