aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-01-08 22:42:20 +0000
committerAdam Soltys <[email protected]>2025-01-14 23:59:47 +0000
commit0a8a8988d27d26feec689a28447eed85c1069584 (patch)
tree61115d0fe28a97081cb4634abfd7cbb3a0e5a44f /lib
parentb21b536817449b88c028a6cbe8ca6f21f4abcb46 (diff)
downloadcoinos-server-0a8a8988d27d26feec689a28447eed85c1069584.tar.gz
coinos-server-0a8a8988d27d26feec689a28447eed85c1069584.zip
prettier
Diffstat (limited to 'lib')
-rw-r--r--lib/lightning.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/lightning.ts b/lib/lightning.ts
index e2c00483..19f6949d 100644
--- a/lib/lightning.ts
+++ b/lib/lightning.ts
@@ -30,6 +30,9 @@ export async function listenForLightning() {
const invoice = await g(`invoice:${id}`);
if (!invoice) return warn("received lightning with no invoice", bolt11);
+ const p = await getPayment(bolt11 || bolt12);
+ if (p) return warn("already processed", bolt11 || bolt12);
+
if (invoice?.memo) {
try {
if (JSON.parse(description).kind === 9734) handleZap(inv);
@@ -39,9 +42,6 @@ export async function listenForLightning() {
}
}
- const p = await getPayment(bolt11 || bolt12);
- if (p) return warn("already processed", bolt11 || bolt12);
-
await credit({
hash: bolt11 || bolt12,
amount: received,
@@ -76,6 +76,9 @@ export async function replay(index) {
const invoice = await g(`invoice:${id}`);
if (!invoice) return warn("received lightning with no invoice", bolt11);
+ const p = await getPayment(bolt11 || bolt12);
+ if (p) return warn("already processed", bolt11 || bolt12);
+
if (invoice?.memo) {
try {
if (JSON.parse(description).kind === 9734) handleZap(inv);
@@ -85,11 +88,6 @@ export async function replay(index) {
}
}
- const p = await getPayment(bolt11 || bolt12);
- if (p) {
- return warn("already processed", bolt11 || bolt12);
- }
-
await credit({
hash: bolt11 || bolt12,
amount: received,