diff options
| author | Adam Soltys <[email protected]> | 2020-06-08 13:04:02 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-06-08 13:04:02 -0700 |
| commit | 7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2 (patch) | |
| tree | b31a06affa4b932990744997c271f6d65502d60c /routes/lightning/send.js | |
| parent | 298672d3f50938ba06a16f8e04d607b7033703b8 (diff) | |
| download | coinos-server-7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2.tar.gz coinos-server-7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2.zip | |
reduce network traffic
Diffstat (limited to 'routes/lightning/send.js')
| -rw-r--r-- | routes/lightning/send.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/routes/lightning/send.js b/routes/lightning/send.js index e3b5c75a..9c4f2259 100644 --- a/routes/lightning/send.js +++ b/routes/lightning/send.js @@ -50,8 +50,9 @@ module.exports = async (req, res) => { max_parts: 10 }); + if (m.payment_error) throw new Error(m.payment_error); + ({ - payment_error: error, payment_route: { total_fees: fee, total_amt: total }, payment_preimage: preimage } = m); @@ -73,11 +74,6 @@ module.exports = async (req, res) => { l.info("lnb sent back", amount); } - if (error) { - l.error("error sending lightning", error); - return res.status(500).send(error); - } - if (seen.includes(preimage)) { l.warn("duplicate payment detected", preimage); throw new Error("Duplicate payment detected"); @@ -108,12 +104,12 @@ module.exports = async (req, res) => { payment = payment.get({ plain: true }); payment.account = account.get({ plain: true }); + emit(user.username, "account", payment.account); + emit(user.username, "payment", payment); + seen.push(preimage); l.info("sent lightning", user.username, total); - user = await getUser(user.username, transaction); - emit(user.username, "user", user); - seen.push(hash); res.send(payment); }); |
