diff options
| author | Adam Soltys <[email protected]> | 2020-05-07 20:15:56 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-05-07 20:58:24 -0700 |
| commit | 47aa48402a0d34dd8ab11f0f315393fcc4f5c61b (patch) | |
| tree | 2e907e64628d26c4707660e854e9bc87b332ff08 /routes/lightning/invoice.js | |
| parent | 2f0f9e640ead76518f7f8013b16704da89421ee4 (diff) | |
| download | coinos-server-47aa48402a0d34dd8ab11f0f315393fcc4f5c61b.tar.gz coinos-server-47aa48402a0d34dd8ab11f0f315393fcc4f5c61b.zip | |
c-lightning support
Diffstat (limited to 'routes/lightning/invoice.js')
| -rw-r--r-- | routes/lightning/invoice.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/routes/lightning/invoice.js b/routes/lightning/invoice.js index f19b3484..3f4ab1db 100644 --- a/routes/lightning/invoice.js +++ b/routes/lightning/invoice.js @@ -3,9 +3,25 @@ module.exports = async (req, res) => { l.info("adding lightning invoice", req.user.username, amount, tip); + /* + const exists = await db.Invoice.findOne({ + where: { + [Op.or]: { + address: invoice.address || "undefined", + text: invoice.text + } + } + }); + */ + try { - const invoice = await lnb.addInvoice({ value: amount + tip }); - res.send(invoice.payment_request); + if (config.lna.clightning) { + const invoice = await lnb.invoice(`${amount + tip}sat` || "any", new Date(), "", 360); + res.send(invoice.bolt11); + } else { + const invoice = await lnb.addInvoice({ value: amount + tip }); + res.send(invoice.payment_request); + } } catch (e) { l.error("problem creating invoice", e.message); res.status(500).send(e.message); |
