diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/payments.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/payments.ts b/lib/payments.ts index 8b1d6366..5984a813 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -1,7 +1,7 @@ import config from "$config"; import api from "$lib/api"; import changeid from "$lib/changeid"; -import { db, g, gf, s } from "$lib/db"; +import { db, g, gf, s, sa } from "$lib/db"; import { broadcastTx, btcNetwork, @@ -356,8 +356,13 @@ export const credit = async ({ p.confirmed = false; balanceKey = "pending"; await s(`payment:${txid}:${vout}`, id); + // Mirror the txid:vout pointer into arc so future bulk /confirm sweeps find + // the prior credit via gf() fallback and don't double-credit even if the + // main-db pointer is wiped by a data-loss event. + await sa(`payment:${txid}:${vout}`, id); } else { await s(`payment:${hash}`, id); + await sa(`payment:${hash}`, id); } let creditType = type; @@ -374,6 +379,10 @@ export const credit = async ({ .set(`${aid || uid}:payments:last`, p.created) .exec(); + // Mirror the payment + invoice records into arc for the same protection. + await sa(`payment:${p.id}`, p); + await sa(`invoice:${inv.id}`, inv); + if (inv.items?.length) { formatReceipt(inv.items, inv.currency); p.items = inv.items; |
