aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lightning.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-03 09:58:47 -0800
committerAdam Soltys <[email protected]>2023-02-03 09:58:47 -0800
commit17a2a698de2a522f05d9ec813411b5a01b95234d (patch)
treef23a88b4dbac920cba169e54f6160aa4c1bab07b /lib/lightning.js
parent549590ceb8bdd2954d2b96c14d530063104b352f (diff)
downloadcoinos-server-17a2a698de2a522f05d9ec813411b5a01b95234d.tar.gz
coinos-server-17a2a698de2a522f05d9ec813411b5a01b95234d.zip
contacts
Diffstat (limited to 'lib/lightning.js')
-rw-r--r--lib/lightning.js9
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);