blob: 89b25b66093b0c2d457774fabc67ce3d4d4984f0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module.exports = (app, db, lnb) => async (req, res) => {
let err = m => res.status(500).send(m);
let { amount, address, tip } = req.body;
let invoice;
try {
invoice = await lnb.addInvoice({ value: amount });
} catch (e) {
return err(e.message);
}
let hash = invoice.payment_request;
if (address) hash = address;
await db.Payment.create({
user_id: req.user.id,
hash,
amount,
currency: "CAD",
rate: app.get("rates").ask,
tip,
confirmed: 1,
});
res.send(invoice);
};
|