aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lightning.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-04-04 00:05:23 -0700
committerAdam Soltys <[email protected]>2023-04-04 00:05:23 -0700
commit0aea60330afff02ad8bb525c5fddd7c367abf03a (patch)
tree52e0ce713368f5ab0f4d40c37f5194dcd55ae1f2 /lib/lightning.js
parent44c59b03f100792708425bbcd806422fa921f1c5 (diff)
downloadcoinos-server-0aea60330afff02ad8bb525c5fddd7c367abf03a.tar.gz
coinos-server-0aea60330afff02ad8bb525c5fddd7c367abf03a.zip
skip processed payments
Diffstat (limited to 'lib/lightning.js')
-rw-r--r--lib/lightning.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/lightning.js b/lib/lightning.js
index c9b41533..7ef62cc9 100644
--- a/lib/lightning.js
+++ b/lib/lightning.js
@@ -15,7 +15,7 @@ export async function listenForLightning() {
pay_index,
status,
msatoshi_received,
- payment_preimage: preimage,
+ payment_preimage: preimage
} = event;
await s("pay_index", pay_index);
@@ -31,6 +31,9 @@ export async function listenForLightning() {
let invoice = await g(`invoice:${hash}`);
if (!invoice) return warn("received lightning with no invoice", bolt11);
+ let payment = await g(`payment:${hash}`);
+ if (payment) return warn("already processed", hash);
+
await credit(hash, received, invoice.memo, preimage, types.lightning);
} catch (e) {
console.log(e);