aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/invoice.js
blob: 51eff332a889aa15e243089cfda2bbb6b843a5f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module.exports = ah(async (req, res) => {
  const { amount, memo, tip } = req.body;

  try {
    if (config.lna.clightning) {
      const invoice = await lnb.invoice(`${amount + tip}sat` || "any", new Date(), memo, 360);
      res.send(invoice.bolt11);
    } else {
      const invoice = await lnb.addInvoice({ value: amount + tip, memo });
      res.send(invoice.payment_request);
    }
  } catch (e) {
    l.error("problem creating invoice", e.message);
    res.status(500).send(e.message);
  }
});