diff options
| author | Adam Soltys <[email protected]> | 2022-11-24 14:04:22 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-11-24 14:04:22 -0800 |
| commit | a675c1992fa58ad04b04a222a1123321268c7af1 (patch) | |
| tree | 90e4da60a3104c99adfeaa820ec9b00496206538 | |
| parent | c3f0689dc728b2ed86792ad180132165479c05d5 (diff) | |
| download | coinos-server-a675c1992fa58ad04b04a222a1123321268c7af1.tar.gz coinos-server-a675c1992fa58ad04b04a222a1123321268c7af1.zip | |
remove lnd support
| -rw-r--r-- | lib/ln.js | 8 | ||||
| -rw-r--r-- | lib/utils.js | 2 | ||||
| -rw-r--r-- | routes/info.js | 13 | ||||
| -rw-r--r-- | routes/lightning/invoice.js | 1 | ||||
| -rw-r--r-- | routes/lightning/receive.js | 55 | ||||
| -rw-r--r-- | routes/lnurl.js | 17 |
6 files changed, 36 insertions, 60 deletions
@@ -1,11 +1,7 @@ import config from "$config"; let ln; -if (config.lna.clightning) { - let { LightningClient } = (await import("clightning-client")).default; - ln = new LightningClient(config.lna.dir); -} else { - ln = await import("./lnd"); -} +let { LightningClient } = (await import("clightning-client")).default; +ln = new LightningClient(config.lna.dir); export default ln; diff --git a/lib/utils.js b/lib/utils.js index c2f7e7eb..c9670339 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -166,10 +166,8 @@ export const derivePayRequest = async ({ amount, memo, tip }) => { if (!tip) tip = 0; let value = amount + tip; - if (config.lna.clightning) { if (!memo) memo = "coinos"; return ( await ln.invoice(value ? `${value}sat` : "any", new Date(), memo, 360) ).bolt11; - } }; diff --git a/routes/info.js b/routes/info.js index 3cbb7c86..eb42ca35 100644 --- a/routes/info.js +++ b/routes/info.js @@ -5,7 +5,6 @@ import store from "$lib/store"; import bc from "$lib/bitcoin"; import lq from "$lib/liquid"; -import lnd from "$lib/lnd"; import ln from "$lib/ln"; import sequelize from "@sequelize/core"; @@ -50,15 +49,9 @@ app.get("/balances", async (req, res, next) => { let lnchannel; let lnwallet; - if (config.lna) { - if (config.lna.clightning) { - const funds = await ln.listfunds(); - lnchannel = parseInt( - funds.channels.reduce((a, b) => a + b.channel_sat, 0) - ); - lnwallet = parseInt(funds.outputs.reduce((a, b) => a + b.value, 0)); - } - } + const funds = await ln.listfunds(); + lnchannel = parseInt(funds.channels.reduce((a, b) => a + b.channel_sat, 0)); + lnwallet = parseInt(funds.outputs.reduce((a, b) => a + b.value, 0)); let bitcoin, bitcoind; if (config.bitcoin) { diff --git a/routes/lightning/invoice.js b/routes/lightning/invoice.js index b5d90faf..ae974120 100644 --- a/routes/lightning/invoice.js +++ b/routes/lightning/invoice.js @@ -1,6 +1,5 @@ import config from "$config"; import { err } from "$lib/logging"; -import lnd from "$lib/lnd"; import ln from "$lib/ln"; import { v4 } from "uuid"; diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index af8415f1..ef973acc 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -6,7 +6,6 @@ import { notify } from "$lib/notifications"; import { callWebhook } from "$lib/webhooks"; import { computeConversionFee } from "./conversionFee"; import { sendLiquid } from "$routes/liquid/send"; -import lnd from "$lib/lnd"; import ln from "$lib/ln"; import { l, err, warn } from "$lib/logging"; @@ -131,35 +130,33 @@ const handlePayment = async msg => { } }; -if (config.lna.clightning) { - const poll = async ln => { - try { - const wait = async i => { - const { - bolt11: request, - pay_index, - status, - msatoshi_received, - payment_preimage: secret - } = await ln.waitanyinvoice(i); +const poll = async ln => { + try { + const wait = async i => { + const { + bolt11: request, + pay_index, + status, + msatoshi_received, + payment_preimage: secret + } = await ln.waitanyinvoice(i); - let settled = status === "paid"; - let received = parseInt(msatoshi_received / 1000); + let settled = status === "paid"; + let received = parseInt(msatoshi_received / 1000); - await handlePayment({ - request, - received, - secret - }); - await wait(pay_index); - }; + await handlePayment({ + request, + received, + secret + }); + await wait(pay_index); + }; - 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); - } - }; + 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); -} +poll(ln); diff --git a/routes/lnurl.js b/routes/lnurl.js index 171acbe5..1ad7b814 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -6,7 +6,6 @@ import { optionalAuth, auth } from "$lib/passport"; import { l, err, warn } from "$lib/logging"; import ln from "$lib/ln"; -import lnd from "$lib/lnd"; import persist from "$lib/persist"; import { emit } from "$lib/sockets"; @@ -16,7 +15,6 @@ import jwt from "jsonwebtoken"; import qs from "query-string"; import bolt11 from "bolt11"; - import { computeConversionFee, conversionFeeReceiver @@ -96,12 +94,10 @@ app.post("/withdraw", auth, async (req, res, next) => { } = req.body; let invoice; - if (config.lna.clightning) { - let label = new Date(); - let desc = label; + let label = new Date(); + let desc = label; - invoice = await ln.invoice(`${value}sats`, label, desc); - } + invoice = await ln.invoice(`${value}sats`, label, desc); const { payment_request: pr } = invoice; const url = `${callback}?k1=${k1}&pr=${pr}`; @@ -394,10 +390,8 @@ lnurlServer.bindToHook( try { let amount; - if (config.lna.clightning) { - let { msatoshi } = await ln.decodepay(pr); - amount = parseInt(msatoshi / 1000); - } + let { msatoshi } = await ln.decodepay(pr); + amount = parseInt(msatoshi / 1000); let conversionFee = computeConversionFee(amount); await db.transaction(async transaction => { @@ -487,7 +481,6 @@ lnurlServer.bindToHook( setTimeout(async () => { try { let { payments } = await ln.getPayments({ - lnd, limit: 5 }); |
