diff options
| author | Adam Soltys <[email protected]> | 2021-01-15 15:31:46 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-01-15 15:31:46 -0800 |
| commit | d01159ce9eee956dca32fd69525c0edd5aae9477 (patch) | |
| tree | e6a4d4a928daffb5bcedbc3411a0dfded6ff422f /routes/send.js | |
| parent | d03dad4d85ccd107068719c4b68cbd6a255864f6 (diff) | |
| download | coinos-server-d01159ce9eee956dca32fd69525c0edd5aae9477.tar.gz coinos-server-d01159ce9eee956dca32fd69525c0edd5aae9477.zip | |
add more transactions and locks
Diffstat (limited to 'routes/send.js')
| -rw-r--r-- | routes/send.js | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/routes/send.js b/routes/send.js index 8a183183..8e5e527b 100644 --- a/routes/send.js +++ b/routes/send.js @@ -2,7 +2,6 @@ const axios = require("axios"); const uuidv4 = require("uuid/v4"); module.exports = ah(async (req, res, next) => { - return res.status(500).send("Internal payments are temporarily disabled"); let { amount, asset, memo, username } = req.body; let { user } = req; amount = parseInt(amount); @@ -84,12 +83,11 @@ module.exports = ah(async (req, res, next) => { if (recipient.account.asset === asset && !recipient.account.pubkey) ({ account: a2 } = recipient); else { - a2 = await db.Account.findOne( - { - where: acc - }, - { transaction } - ); + a2 = await db.Account.findOne({ + where: acc, + lock: transaction.LOCK.UPDATE, + transaction + }); } if (a2) { @@ -106,16 +104,15 @@ module.exports = ah(async (req, res, next) => { if (assets[asset]) { ({ domain, ticker, precision, name } = assets[asset]); } else { - const existing = await db.Account.findOne( - { - where: { - asset - }, - order: [["id", "ASC"]], - limit: 1 + const existing = await db.Account.findOne({ + where: { + asset }, - { transaction } - ); + order: [["id", "ASC"]], + limit: 1, + lock: transaction.LOCK.UPDATE, + transaction + }); if (existing) { ({ domain, ticker, precision, name } = existing); |
