aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-14 11:01:07 -0700
committerAdam Soltys <[email protected]>2024-10-14 11:01:07 -0700
commit3d879583de7722ce0e962930dcf96bbf9c6d9195 (patch)
tree158772dee5c87c556b5b343d448b2245c247b9df /lib
parent0c24ae9feedbcc90d88b6dc1be46095fb786dd93 (diff)
downloadcoinos-server-3d879583de7722ce0e962930dcf96bbf9c6d9195.tar.gz
coinos-server-3d879583de7722ce0e962930dcf96bbf9c6d9195.zip
add to pending right away
Diffstat (limited to 'lib')
-rw-r--r--lib/payments.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index 705245e8..a073bec7 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -512,6 +512,7 @@ export let sendLightning = async ({
if (pays.find((p) => p.status === "pending"))
fail("Payment is already underway");
+ await db.sAdd("pending", pr);
p = await debit({
hash: pr,
amount: total,
@@ -533,8 +534,10 @@ export let sendLightning = async ({
});
try {
- if (r.status === "complete") p = await finalize(r, p);
- else await db.sAdd("pending", pr);
+ if (r.status === "complete") {
+ p = await finalize(r, p);
+ await db.sRem("pending", pr);
+ }
} catch (e) {
console.log("failed to process payment", e, p);
}