diff options
| -rw-r--r-- | routes/bitcoin/receive.js | 5 | ||||
| -rw-r--r-- | routes/liquid/receive.js | 3 | ||||
| -rw-r--r-- | routes/swaps.js | 10 |
3 files changed, 14 insertions, 4 deletions
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js index f4fd4294..d0ac0ce5 100644 --- a/routes/bitcoin/receive.js +++ b/routes/bitcoin/receive.js @@ -136,7 +136,7 @@ setInterval(async () => { const hash = arr[i]; await db.transaction(async (transaction) => { - const p = await db.Payment.findOne({ + let p = await db.Payment.findOne({ where: { hash, confirmed: 0, received: 1 }, include: [ { @@ -164,6 +164,9 @@ setInterval(async () => { await p.account.save({ transaction }); await p.save({ transaction }); + let p = p.get({ plain: true }); + p.account = p.account.get({ plain: true }); + emit(user.username, "account", p.account); emit(user.username, "payment", p); l.info("bitcoin confirmed", user.username, p.amount, p.tip); diff --git a/routes/liquid/receive.js b/routes/liquid/receive.js index 580b6597..77693cb6 100644 --- a/routes/liquid/receive.js +++ b/routes/liquid/receive.js @@ -225,7 +225,7 @@ setInterval(async () => { const hash = arr[i]; await db.transaction(async (transaction) => { - const p = await db.Payment.findOne({ + let p = await db.Payment.findOne({ where: { hash, confirmed: 0, received: 1 }, include: [ { @@ -252,6 +252,7 @@ setInterval(async () => { await p.account.save({ transaction }); await p.save({ transaction }); + p = p.get({ plain: true }); p.account = p.account.get({ plain: true }); emit(user.username, "account", p.account); diff --git a/routes/swaps.js b/routes/swaps.js index b1d1e281..7a7f6592 100644 --- a/routes/swaps.js +++ b/routes/swaps.js @@ -249,9 +249,13 @@ app.post("/accept", optionalAuth, async (req, res) => { proposal.accepted = true; await proposal.save({ transaction }); + l1a1p = l1a1p.get({ plain: true }); l1a1p.account = l1a1.get({ plain: true }); + l1a2p = l1a2p.get({ plain: true }); l1a2p.account = l1a2.get({ plain: true }); + l2a1p = l2a1p.get({ plain: true }); l2a1p.account = l2a1.get({ plain: true }); + l2a2p = l2a2p.get({ plain: true }); l2a2p.account = l2a2.get({ plain: true }); emit(user.username, "account", l1a1); @@ -298,7 +302,7 @@ app.post("/accept", optionalAuth, async (req, res) => { l1a2.balance -= amount; btc.balance -= fee; - const payment = await db.Payment.create({ + let payment = await db.Payment.create({ hash, amount: -amount, account_id: l1a2.id, @@ -313,7 +317,6 @@ app.post("/accept", optionalAuth, async (req, res) => { network: "LBTC", }); - payment.account = l1a2.get({ plain: true }); amount = Math.round(leg2.amount * SATS); await db.Invoice.create({ @@ -336,6 +339,9 @@ app.post("/accept", optionalAuth, async (req, res) => { proposal.accepted = true; await proposal.save({ transaction }); + payment = payment.get({ plain: true }); + payment.account = l1a2.get({ plain: true }); + emit(proposal.user.username, "payment", payment); emit(proposal.user.username, "account", l1a2); emit(proposal.user.username, "account", btc); |
