diff options
| author | Adam Soltys <[email protected]> | 2020-04-27 21:42:10 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-04-28 22:33:02 -0700 |
| commit | 994dd93f6c45c590ae59a699cbf425d96518da1e (patch) | |
| tree | 89b2a980fbad1e964e91ca3750b89051ddfb32f0 /routes/lightning/user.js | |
| parent | e166ab2c743e4c66eacb51c6484711c5965dd090 (diff) | |
| download | coinos-server-994dd93f6c45c590ae59a699cbf425d96518da1e.tar.gz coinos-server-994dd93f6c45c590ae59a699cbf425d96518da1e.zip | |
fix lightning payments
Diffstat (limited to 'routes/lightning/user.js')
| -rw-r--r-- | routes/lightning/user.js | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/routes/lightning/user.js b/routes/lightning/user.js index 36af2718..41bd507f 100644 --- a/routes/lightning/user.js +++ b/routes/lightning/user.js @@ -9,6 +9,13 @@ module.exports = async (req, res) => { } }); + const account = await db.Account.findOne({ + where: { + user_id: user.id, + asset: config.liquid.btcasset + } + }); + l.info("paying user", req.user.username, payuser); if (!user) { @@ -27,6 +34,7 @@ module.exports = async (req, res) => { await db.Payment.create({ user_id: user.id, + account_id: account.id, hash, amount, rate: app.get("rates")[req.user.currency], @@ -34,23 +42,11 @@ module.exports = async (req, res) => { tip: 0, confirmed: true, received: false, - network : "LNBTC" + network: "LNBTC" }); req.url = "/lightning/send"; let payreq = bolt11.decode(hash); - 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); }; |
