aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/send.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/lightning/send.js')
-rw-r--r--routes/lightning/send.js14
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);
});