aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/query.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/lightning/query.js')
-rw-r--r--routes/lightning/query.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/routes/lightning/query.js b/routes/lightning/query.js
index 48af8b8e..6e70f30a 100644
--- a/routes/lightning/query.js
+++ b/routes/lightning/query.js
@@ -4,9 +4,25 @@ module.exports = async (req, res) => {
let { amount, payreq } = req.body;
try {
+ let invoice = await db.Invoice.findOne({
+ where: { text: payreq },
+ include: {
+ model: db.User,
+ as: "user"
+ }
+ });
+
+ if (invoice) emit(req.user.username, "to", invoice.user);
+
payreq = bolt11.decode(payreq);
- res.send(await lna.queryRoutes({ pub_key: payreq.payeeNodeKey, amt: amount || payreq.satoshis }));
+
+ res.send(
+ await lna.queryRoutes({
+ pub_key: payreq.payeeNodeKey,
+ amt: amount || payreq.satoshis
+ })
+ );
} catch (e) {
res.status(500).send(e.message);
- }
+ }
};