From b5607df482440b55bd3e802f5bea4ead95e6491e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 8 Sep 2020 07:26:14 -0700 Subject: bump account index --- routes/send.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'routes/send.js') diff --git a/routes/send.js b/routes/send.js index 616ac137..cafbaed8 100644 --- a/routes/send.js +++ b/routes/send.js @@ -63,6 +63,23 @@ module.exports = ah(async (req, res, next) => { where: { username }, }); + + const invoice = await db.Invoice.findOne({ + where: { + user_id: user.id, + network: "BTC" + }, + order: [["id", "DESC"]], + include: { + model: db.Account, + as: "account", + }, + }); + + if (invoice) ({ account } = invoice); + else if (user.account.asset === asset) ({ account } = user); + else { + let params = { user_id: user.id, asset, @@ -73,6 +90,7 @@ module.exports = ah(async (req, res, next) => { lock: transaction.LOCK.UPDATE, transaction, }); + } if (account) { account.balance += amount; -- cgit v1.2.3