diff options
Diffstat (limited to 'lib/lightning.js')
| -rw-r--r-- | lib/lightning.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/lightning.js b/lib/lightning.js index c8daf8c8..2915b7c7 100644 --- a/lib/lightning.js +++ b/lib/lightning.js @@ -8,6 +8,7 @@ import { g, s, t, db } from "$lib/db"; import { credit, types } from "$lib/payments"; export async function listenForLightning() { + let event = await ln.waitanyinvoice(await g("pay_index")); let { payment_hash: hash, bolt11, @@ -15,7 +16,7 @@ export async function listenForLightning() { status, msatoshi_received, payment_preimage: preimage - } = await ln.waitanyinvoice(await g("pay_index")); + } = event; await s("pay_index", pay_index); setTimeout(listenForLightning); @@ -30,11 +31,7 @@ export async function listenForLightning() { let invoice = await g(`invoice:${hash}`); if (!invoice) return warn("received lightning with no invoice", bolt11); - let { currency, memo, rate, tip, uid } = invoice; - let amount = parseInt(received) - tip; - if (amount < 0) throw new Error("amount out of range"); - - await credit(hash, amount, memo, preimage, types.lightning); + await credit(hash, received, invoice.memo, preimage, types.lightning); } catch (e) { console.log(e); err("problem receiving lightning payment", e.message); |
