From 7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 8 Jun 2020 13:04:02 -0700 Subject: reduce network traffic --- routes/lightning/send.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'routes/lightning/send.js') 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); }); -- cgit v1.2.3