aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-03-27 22:52:28 -0700
committerAdam Soltys <[email protected]>2020-03-27 22:52:28 -0700
commita4c3ecab30a279db7ed7f7289448c01c73c7b523 (patch)
treee7897dfe836f1435c96cec84df51e781cafece59
parentd1f87762cc4d665fa364c848e846eb121269b2e4 (diff)
downloadcoinos-server-a4c3ecab30a279db7ed7f7289448c01c73c7b523.tar.gz
coinos-server-a4c3ecab30a279db7ed7f7289448c01c73c7b523.zip
handle pay user error
-rw-r--r--routes/lightning/user.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/routes/lightning/user.js b/routes/lightning/user.js
index bb812e05..34659a6c 100644
--- a/routes/lightning/user.js
+++ b/routes/lightning/user.js
@@ -34,14 +34,22 @@ module.exports = async (req, res) => {
tip: 0,
confirmed: true,
received: false,
- asset: 'LNBTC',
+ asset: "LNBTC"
});
req.url = "/lightning/send";
let payreq = bolt11.decode(hash);
- const { routes } = await lna.queryRoutes({ "pub_key": payreq.payeeNodeKey, "amt": payreq.satoshis });
- if (routes.length) req.body.route = routes[0];
- else return res.status(500).send("No route available");
+ try {
+ const { routes } = await lna.queryRoutes({
+ pub_key: payreq.payeeNodeKey,
+ amt: payreq.satoshis
+ });
+ if (routes.length) req.body.route = routes[0];
+ else return res.status(500).send("No route available");
+ } catch (e) {
+ l.warn("no route available", e);
+ return res.status(500).send("No route available");
+ }
req.body.payreq = hash;
return app._router.handle(req, res);