From 6b00db46ec0f75d08c3fff77bcef45b9af891553 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 9 Jul 2020 00:56:50 -0400 Subject: return payment --- lib/send.js | 7 ++++++- routes/lightning/send.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/send.js b/lib/send.js index 2e04c5d4..71209456 100644 --- a/lib/send.js +++ b/lib/send.js @@ -12,6 +12,8 @@ send = async (amount, hash, user) => { throw new Error("Invoice has been paid, can't pay again"); } + let payment; + await db.transaction(async (transaction) => { let account = await db.Account.findOne({ where: { @@ -85,7 +87,7 @@ send = async (amount, hash, user) => { account.balance -= total; await account.save({ transaction }); - let payment = await db.Payment.create( + payment = await db.Payment.create( { amount: -total, account_id: account.id, @@ -111,5 +113,8 @@ send = async (amount, hash, user) => { seen.push(hash); l.info("sent lightning", user.username, total); + }); + + return payment; }; diff --git a/routes/lightning/send.js b/routes/lightning/send.js index ed561c52..60732425 100644 --- a/routes/lightning/send.js +++ b/routes/lightning/send.js @@ -4,7 +4,7 @@ module.exports = async (req, res) => { let { user } = req; try { - res.send(await send(amount, pr, user)); + res.send(await send(amount, payreq, user)); } catch (e) { l.error("problem sending lightning payment", user.username, e.message); throw new Error(e.message); -- cgit v1.2.3