diff options
| author | Adam Soltys <[email protected]> | 2020-09-07 20:04:33 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-09-07 20:04:33 -0700 |
| commit | e40e68f49b10d6ef70546f7128bad891256525c0 (patch) | |
| tree | f2f0b832eb9f8655c7d4bfca7c2ce12aa9634b5c /routes/bitcoin | |
| parent | f82838d4682de4717f6a66be2a7903fdab83cbce (diff) | |
| download | coinos-server-e40e68f49b10d6ef70546f7128bad891256525c0.tar.gz coinos-server-e40e68f49b10d6ef70546f7128bad891256525c0.zip | |
multiple same-asset accounts
Diffstat (limited to 'routes/bitcoin')
| -rw-r--r-- | routes/bitcoin/send.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js index 5e52b7ed..8745c3dd 100644 --- a/routes/bitcoin/send.js +++ b/routes/bitcoin/send.js @@ -9,7 +9,7 @@ module.exports = ah(async (req, res) => { const isChange = async address => (await bc.getAddressInfo(address)).ismine && - (!Object.keys(addresses).includes(address)); + !Object.keys(addresses).includes(address); tx = await bc.decodeRawTransaction(hex); @@ -30,17 +30,20 @@ module.exports = ah(async (req, res) => { total = total - change + fee; let amount = total - fee; - let account, params; + let { account } = user; + let params; try { await db.transaction(async transaction => { - account = await db.Account.findOne({ - where: { - user_id: user.id, - asset: config.liquid.btcasset - }, - lock: transaction.LOCK.UPDATE, - transaction - }); + if (account.asset !== btcasset) { + account = await db.Account.findOne({ + where: { + user_id: user.id, + asset: config.liquid.btcasset + }, + lock: transaction.LOCK.UPDATE, + transaction + }); + } if (total > account.balance) { l.error("amount exceeds balance", amount, fee, account.balance); |
