From c4aba2cfd76eeaa0a177a4a92ca4539f5bf61e52 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 4 Jun 2026 23:38:32 -0700 Subject: payments: clarify deposit log (pending vs confirmed) to stop phantom double-receive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit completePayment logs once when an on-chain deposit is first seen (pending) and again from /confirm when it confirms, both as bare "received" — so a single liquid/bitcoin deposit appeared twice in the logs and looked like a double credit. It never was (the /confirm p.confirmed guard and the seen set prevent double-crediting); purely misleading log noise. Now logs "receiving (pending)" on first sight and "received" on confirmation. Instant lightning receives are confirmed=true so they still log a single "received". Co-Authored-By: Claude Opus 4.8 (1M context) --- lib/payments.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/payments.ts b/lib/payments.ts index acc9a462..f10559be 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -404,7 +404,15 @@ export const completePayment = async (inv, p, user) => { squarePayment(p, user); - l(username, "received", p.type, p.amount); + // completePayment runs at two lifecycle points for on-chain (bitcoin/liquid) + // deposits — once when the tx is first seen (pending) and again from /confirm + // when it confirms — plus once for instant lightning receives. Logging a bare + // "received" at each made a single on-chain deposit look like two receives in + // the logs (it never double-credited — the /confirm `p.confirmed` guard and + // the `seen` set prevent that; it was only noisy/misleading). Distinguish the + // states so the log reads as one deposit moving pending -> confirmed. + const stage = p.confirmed ? "received" : "receiving (pending)"; + l(username, stage, p.type, p.amount); callWebhook(inv, p); }; -- cgit v1.2.3