aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-05-31 10:34:51 -0700
committerAdam Soltys <[email protected]>2022-05-31 10:34:51 -0700
commit72e945305349cf18d45e74e9537e9adbd655c68c (patch)
tree5db35f51d507a0475839e1af44945e9ab270e3a2
parent2200e185f7099defdad3e510e7f74c84017d833b (diff)
downloadcoinos-server-72e945305349cf18d45e74e9537e9adbd655c68c.tar.gz
coinos-server-72e945305349cf18d45e74e9537e9adbd655c68c.zip
do fee decrement as part of single db transaction
-rw-r--r--routes/bitcoin/send.js7
1 files changed, 3 insertions, 4 deletions
diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js
index 51962367..67857121 100644
--- a/routes/bitcoin/send.js
+++ b/routes/bitcoin/send.js
@@ -70,10 +70,7 @@ module.exports = ah(async (req, res) => {
await account.decrement({ balance: (total + withdrawalFee) }, { transaction });
await account.reload({ transaction });
- });
- // pay withdrawal fee to receiver
- await db.transaction(async transaction => {
let receiverAccount = await db.Account.findOne({
where: {
"$user.username$": withdrawalFeeReceiver
@@ -101,7 +98,9 @@ module.exports = ah(async (req, res) => {
confirmed: true,
received: true,
network: "COINOS"
- });
+ },
+ { transaction }
+ );
});
// record the external bitcoin transaction