diff options
| -rw-r--r-- | lib/lightning.ts | 14 |
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, |
