aboutsummaryrefslogtreecommitdiffstats
path: root/routes/bitcoin/receive.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-01-15 15:31:46 -0800
committerAdam Soltys <[email protected]>2021-01-15 15:31:46 -0800
commitd01159ce9eee956dca32fd69525c0edd5aae9477 (patch)
treee6a4d4a928daffb5bcedbc3411a0dfded6ff422f /routes/bitcoin/receive.js
parentd03dad4d85ccd107068719c4b68cbd6a255864f6 (diff)
downloadcoinos-server-d01159ce9eee956dca32fd69525c0edd5aae9477.tar.gz
coinos-server-d01159ce9eee956dca32fd69525c0edd5aae9477.zip
add more transactions and locks
Diffstat (limited to 'routes/bitcoin/receive.js')
-rw-r--r--routes/bitcoin/receive.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js
index e0e3828b..2a6a7954 100644
--- a/routes/bitcoin/receive.js
+++ b/routes/bitcoin/receive.js
@@ -159,10 +159,13 @@ setInterval(async () => {
let total = p.amount + p.tip;
p.confirmed = 1;
- p.account.balance += total;
- p.account.pending -= Math.min(p.account.pending, total);
-
await p.account.save({ transaction });
+ await p.account.increment({ balance: total }, { transaction });
+ await p.account.decrement(
+ { pending: Math.min(p.account.pending, total) },
+ { transaction }
+ );
+ await p.account.reload({ transaction });
await p.save({ transaction });
p = p.get({ plain: true });