aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning
diff options
context:
space:
mode:
Diffstat (limited to 'routes/lightning')
-rw-r--r--routes/lightning/receive.js54
-rw-r--r--routes/lightning/send.js2
2 files changed, 27 insertions, 29 deletions
diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js
index 6befc7a3..f70867ac 100644
--- a/routes/lightning/receive.js
+++ b/routes/lightning/receive.js
@@ -1,36 +1,34 @@
-module.exports = {
- const handlePayment = async msg => {
- if (!msg.settled) return;
+const handlePayment = async msg => {
+ if (!msg.settled) return;
- let payment = await db.Payment.findOne({
- include: { model: db.User, as: "user" },
- where: {
- hash: msg.payment_request
- }
- });
+ let payment = await db.Payment.findOne({
+ include: { model: db.User, as: "user" },
+ where: {
+ hash: msg.payment_request
+ }
+ });
- if (!payment) return;
+ if (!payment) return;
- const { user } = payment;
+ const { user } = payment;
- payment.received = true;
- user.balance += parseInt(msg.value);
- payment.rate = app.get("rates")[user.currency];
- payment.confirmed = true;
- payment.currency = user.currency;
+ payment.received = true;
+ user.balance += parseInt(msg.value);
+ payment.rate = app.get("rates")[user.currency];
+ payment.confirmed = true;
+ payment.currency = user.currency;
- await payment.save();
- await user.save();
- payments.push(msg.payment_request);
- l.info("lightning payment received", user.username, payment.amount);
+ await payment.save();
+ await user.save();
+ payments.push(msg.payment_request);
+ l.info("lightning payment received", user.username, payment.amount);
- emit(user.username, "payment", payment);
- emit(user.username, "user", user);
- };
+ emit(user.username, "payment", payment);
+ emit(user.username, "user", user);
+};
- const invoices = lna.subscribeInvoices({});
- invoices.on("data", handlePayment);
+const invoices = lna.subscribeInvoices({});
+invoices.on("data", handlePayment);
- const invoicesb = lnb.subscribeInvoices({});
- invoicesb.on("data", handlePayment);
-};
+const invoicesb = lnb.subscribeInvoices({});
+invoicesb.on("data", handlePayment);
diff --git a/routes/lightning/send.js b/routes/lightning/send.js
index 2b661b60..38023a1d 100644
--- a/routes/lightning/send.js
+++ b/routes/lightning/send.js
@@ -30,7 +30,7 @@ module.exports = async (req, res) => {
await user.save({ transaction });
});
} catch (e) {
- l.warn("insufficient funds for lightning payment", e);
+ l.warn("insufficient funds for lightning payment", user.username);
return res.status(500).send("Not enough satoshis");
}