chore: prevent duplicate Lightning charges by adding durable invoice-level NWC payment guard

This commit is contained in:
2026-04-25 16:42:05 +05:30
parent 1aeb15971d
commit d9c7e0c1e4
4 changed files with 214 additions and 31 deletions
@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS invoice_nwc_payment (
invoice_id TEXT PRIMARY KEY,
tenant_pubkey TEXT NOT NULL,
state TEXT NOT NULL CHECK (state IN ('pending', 'paid')),
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
FOREIGN KEY (tenant_pubkey) REFERENCES tenant(pubkey)
);
CREATE INDEX IF NOT EXISTS idx_invoice_nwc_payment_tenant_pubkey
ON invoice_nwc_payment (tenant_pubkey);