From 72e945305349cf18d45e74e9537e9adbd655c68c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 31 May 2022 10:34:51 -0700 Subject: do fee decrement as part of single db transaction --- routes/bitcoin/send.js | 7 +++---- 1 file 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 -- cgit v1.2.3