aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-09-17 00:55:40 -0700
committerAdam Soltys <[email protected]>2020-09-17 10:02:48 -0700
commit0904ac984bb2aff0a862a0157f8f2feead1b1c83 (patch)
tree8f57cd9377c4d95df716825f41648a04558a896c
parent06e5bc372b07666e5d90efc8042b42ef54731478 (diff)
downloadcoinos-server-0904ac984bb2aff0a862a0157f8f2feead1b1c83.tar.gz
coinos-server-0904ac984bb2aff0a862a0157f8f2feead1b1c83.zip
use current account for internal payments
-rw-r--r--routes/send.js10
-rw-r--r--routes/users.js2
2 files changed, 2 insertions, 10 deletions
diff --git a/routes/send.js b/routes/send.js
index aea0a858..e2836b82 100644
--- a/routes/send.js
+++ b/routes/send.js
@@ -10,14 +10,7 @@ module.exports = ah(async (req, res, next) => {
try {
await db.transaction(async transaction => {
- let account = await db.Account.findOne({
- where: {
- user_id: user.id,
- asset
- },
- lock: transaction.LOCK.UPDATE,
- transaction
- });
+ let { account } = user;
if (account.balance < amount) {
throw new Error("Insufficient funds");
@@ -149,7 +142,6 @@ module.exports = ah(async (req, res, next) => {
user.username,
user.balance,
e.message,
- e.stack
);
return res.status(500).send(e.message);
}
diff --git a/routes/users.js b/routes/users.js
index 5de71a54..e92bc874 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -455,7 +455,7 @@ app.post(
try {
const account = await db.Account.findOne({
- where: { id }
+ where: { id, user_id: user.id }
});
user.account_id = account.id;