aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-04 23:38:32 -0700
committerAdam Soltys <[email protected]>2026-06-04 23:38:32 -0700
commitc4aba2cfd76eeaa0a177a4a92ca4539f5bf61e52 (patch)
tree5ffdfe6a26dd3ef31d6b93a27a2081b180349953
parentce9616f62d0ac682c1e92956ef4cb48f053df27d (diff)
downloadcoinos-server-c4aba2cfd76eeaa0a177a4a92ca4539f5bf61e52.tar.gz
coinos-server-c4aba2cfd76eeaa0a177a4a92ca4539f5bf61e52.zip
payments: clarify deposit log (pending vs confirmed) to stop phantom double-receive
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) <[email protected]>
-rw-r--r--lib/payments.ts10
1 files changed, 9 insertions, 1 deletions
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);
};