diff options
| author | Adam Soltys <[email protected]> | 2020-04-28 22:09:22 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-04-28 22:33:02 -0700 |
| commit | 63c18105e6c66b3b4698c398f356bef1b496816f (patch) | |
| tree | e7ee85e7c3502ed81954448a76be028143990948 /routes/lightning | |
| parent | 994dd93f6c45c590ae59a699cbf425d96518da1e (diff) | |
| download | coinos-server-63c18105e6c66b3b4698c398f356bef1b496816f.tar.gz coinos-server-63c18105e6c66b3b4698c398f356bef1b496816f.zip | |
include account in emitted payments objects
Diffstat (limited to 'routes/lightning')
| -rw-r--r-- | routes/lightning/receive.js | 4 | ||||
| -rw-r--r-- | routes/lightning/send.js | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index 0805c878..97fe07dc 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -21,7 +21,7 @@ const handlePayment = async msg => { } }); - const payment = await db.Payment.create({ + let payment = await db.Payment.create({ account_id: account.id, user_id, hash, @@ -44,6 +44,8 @@ const handlePayment = async msg => { let user = await getUserById(user_id) + payment = payment.get({ plain: true }); + payment.account = account.get({ plain: true }); emit(user.username, "payment", payment); emit(user.username, "user", user); diff --git a/routes/lightning/send.js b/routes/lightning/send.js index 02149aa8..6f21cc9b 100644 --- a/routes/lightning/send.js +++ b/routes/lightning/send.js @@ -67,7 +67,7 @@ module.exports = async (req, res) => { account.balance -= total - payreq.satoshis; await account.save() - const payment = await db.Payment.create({ + let payment = await db.Payment.create({ amount: -total, account_id: account.id, user_id: user.id, @@ -78,11 +78,13 @@ module.exports = async (req, res) => { network: "LNBTC" }); + payment = payment.get({ plain: true }); + payment.account = account.get({ plain: true }); + seen.push(m.payment_preimage); l.info("sent lightning", user.username, -payment.amount, m); user = await getUser(user.username); - emit(user.username, "payment", payment); emit(user.username, "user", user); if (payreq.payeeNodeKey === config.lnb.id) { @@ -99,7 +101,7 @@ module.exports = async (req, res) => { seen.push(hash); res.send(payment); } catch (e) { - l.info("error sending lightning", e); + l.info("error sending lightning", e.message); return res.status(500).send(e); } }; |
