aboutsummaryrefslogtreecommitdiffstats
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
parent0c24ae9feedbcc90d88b6dc1be46095fb786dd93 (diff)
downloadcoinos-server-3d879583de7722ce0e962930dcf96bbf9c6d9195.tar.gz
coinos-server-3d879583de7722ce0e962930dcf96bbf9c6d9195.zip
add to pending right away
-rw-r--r--lib/payments.ts7
-rw-r--r--routes/nostr.ts2
2 files changed, 6 insertions, 3 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);
}
diff --git a/routes/nostr.ts b/routes/nostr.ts
index ddec8803..99b2a5c3 100644
--- a/routes/nostr.ts
+++ b/routes/nostr.ts
@@ -85,7 +85,7 @@ export default {
await s(`${pubkeys}:pubkeys`, pubkeys);
}
- if (!pubkeys.length || pubkeysOnly) return res.send(pubkeys);
+ if (!pubkeys.length || pubkeysOnly) return res.send(pubkeys);
let cache = await g(`${pubkey}:follows`);
if (cache && cache.t >= created_at) ({ follows } = cache);