diff options
| author | Adam Soltys <[email protected]> | 2022-09-22 02:57:54 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-22 02:57:54 +0000 |
| commit | 3f18d0c8ab508553062bf92a17295961f91a4822 (patch) | |
| tree | 4608fc9f51820cdd48abc6352ddaf83f0e1208e3 /routes/lightning/receive.js | |
| parent | 45ae80bcde258622108c6d66e404660b0c037eb8 (diff) | |
| parent | 918813a6e49f9d05828f6fb205614f9d288269e1 (diff) | |
| download | coinos-server-3f18d0c8ab508553062bf92a17295961f91a4822.tar.gz coinos-server-3f18d0c8ab508553062bf92a17295961f91a4822.zip | |
Merge remote-tracking branch 'origin/master' into prod2
Diffstat (limited to 'routes/lightning/receive.js')
| -rw-r--r-- | routes/lightning/receive.js | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index 56714da7..084161b5 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -8,11 +8,11 @@ import { computeConversionFee } from "./conversionFee"; import { sendLiquid } from "$routes/liquid/send"; import { subscribeToInvoices } from "lightning"; import lnd from "$lib/lnd"; +import ln from "$lib/ln"; import { l, err, warn } from "$lib/logging"; const handlePayment = async msg => { try { - console.log(msg) l("incoming lightning payment", msg.received); if (!msg.secret) return; @@ -134,29 +134,33 @@ const handlePayment = async msg => { if (config.lna.clightning) { const poll = async ln => { - const wait = async i => { - const { - bolt11: payment_request, - pay_index, - status, - msatoshi_received, - payment_preimage: r_preimage - } = await ln.waitanyinvoice(i); + try { + const wait = async i => { + const { + bolt11: request, + pay_index, + status, + msatoshi_received, + payment_preimage: secret + } = await ln.waitanyinvoice(i); + console.log("um"); - let settled = status === "paid"; - let amt_paid_sat = parseInt(msatoshi_received / 1000); + let settled = status === "paid"; + let received = parseInt(msatoshi_received / 1000); - await handlePayment({ - payment_request, - settled, - amt_paid_sat, - r_preimage - }); - wait(pay_index); - }; + await handlePayment({ + request, + received, + secret + }); + await wait(pay_index); + }; - const { invoices } = await ln.listinvoices(); - wait(Math.max(...invoices.map(i => i.pay_index).filter(n => n))); + const { invoices } = await ln.listinvoices(); + await wait(Math.max(...invoices.map(i => i.pay_index).filter(n => n))); + } catch (e) { + err("problem waiting for c-lightning invoice", e.message); + } }; poll(ln); |
