diff options
| author | Adam Soltys <[email protected]> | 2022-09-20 22:48:18 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-20 22:48:18 -0700 |
| commit | 4569736bac949bd2b06ce03b11299b11984e8d3c (patch) | |
| tree | d4e7c71c5be97903a43e0e25f816b2a4b9fde0a5 /routes/lnurl.js | |
| parent | f2fb6b587bb171101b0f91722c0c29e358b386e0 (diff) | |
| parent | b53875cf6bdf47c359139aa846c6597fa3627c87 (diff) | |
| download | coinos-server-4569736bac949bd2b06ce03b11299b11984e8d3c.tar.gz coinos-server-4569736bac949bd2b06ce03b11299b11984e8d3c.zip | |
Merge branch 'master' into prod
Diffstat (limited to 'routes/lnurl.js')
| -rw-r--r-- | routes/lnurl.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js index 547a41dd..fc2e5a52 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -91,7 +91,17 @@ app.post("/withdraw", auth, async (req, res, next) => { amount: value, params: { callback, k1 } } = req.body; - const invoice = await createInvoice({ lnd, value }); + + let invoice; + if (config.lna.clightning) { + let label = new Date(); + let desc = label; + + invoice = await ln.invoice(`${value}sats`, label, desc); + } else { + invoice = await createInvoice({ lnd, value }); + } + const { payment_request: pr } = invoice; const url = `${callback}?k1=${k1}&pr=${pr}`; @@ -260,6 +270,7 @@ app.get("/decode", async (req, res, next) => { } const { data: params } = await axios.get(url); + res.send(params); } catch (e) { err("problem decoding lnurl", e.message); @@ -366,8 +377,14 @@ lnurlServer.bindToHook( } try { - let decoded = await decodePaymentRequest({ lnd, request: pr }); - let amount = decoded.num_satoshis; + let amount; + + if (config.lna.clightning) { + let { msatoshi } = await ln.decodepay(pr); + amount = parseInt(msatoshi/1000); + } else { + ({ num_satoshis: amount } = await decodePaymentRequest({ lnd, request: pr })); + } let conversionFee = computeConversionFee(amount); await db.transaction(async transaction => { |
