From 8bb34972854d0a046ebce7704579ceef56ea1ce5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 28 Sep 2020 01:18:27 -0700 Subject: update account balances --- routes/swaps.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/routes/swaps.js b/routes/swaps.js index aaf9bcc1..92b2d7ba 100644 --- a/routes/swaps.js +++ b/routes/swaps.js @@ -237,6 +237,9 @@ app.post( { transaction } ); + p.acc1.balance += v2; + await p.acc1.save({ transaction }); + emit(p.user.username, "payment", payment); emit(p.user.username, "account", p.acc1); @@ -255,6 +258,9 @@ app.post( { transaction } ); + a1acc.balance += v1; + await a1acc.save({ transaction }); + emit(user.username, "payment", payment); emit(user.username, "account", a1acc); } else { @@ -284,6 +290,9 @@ app.post( { transaction } ); + a2acc.balance += p.v1; + await a2acc.save({ transaction }); + emit(user.username, "payment", payment); emit(user.username, "account", a2acc); @@ -302,6 +311,9 @@ app.post( { transaction } ); + p.acc2.balance += p.v2; + await p.acc2.save({ transaction }); + emit(p.user.username, "payment", payment); emit(p.user.username, "account", p.acc2); @@ -311,8 +323,6 @@ app.post( transaction ); - btc.balance += p.fee; - payment = await db.Payment.create( { hash: "Swap Fee Refund", @@ -328,6 +338,9 @@ app.post( { transaction } ); + btc.balance += p.fee; + await btc.save({ transaction }); + emit(p.user.username, "payment", payment); emit(p.user.username, "account", btc); } -- cgit v1.2.3