aboutsummaryrefslogtreecommitdiffstats
path: root/routes/send.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-05-18 17:46:20 -0700
committerAdam Soltys <[email protected]>2020-05-18 17:46:20 -0700
commitaf2d18b6508a3b50ee8272850707b5bf8c0e50a2 (patch)
treea75fb42f37f12c8557534e29b48cfac57ad30274 /routes/send.js
parente8c461d90eb0f9618129a23b771851fdfec6edb1 (diff)
downloadcoinos-server-af2d18b6508a3b50ee8272850707b5bf8c0e50a2.tar.gz
coinos-server-af2d18b6508a3b50ee8272850707b5bf8c0e50a2.zip
handle reissuance tokens
Diffstat (limited to 'routes/send.js')
-rw-r--r--routes/send.js31
1 files changed, 23 insertions, 8 deletions
diff --git a/routes/send.js b/routes/send.js
index bca04e6b..7091c4bc 100644
--- a/routes/send.js
+++ b/routes/send.js
@@ -9,14 +9,14 @@ module.exports = async (req, res) => {
return res.status(500).send("Amount must be greater than zero");
try {
- await db.transaction(async (transaction) => {
+ await db.transaction(async transaction => {
let account = await db.Account.findOne({
where: {
user_id: user.id,
- asset,
+ asset
},
lock: transaction.LOCK.UPDATE,
- transaction,
+ transaction
});
if (account.balance < amount) {
@@ -37,7 +37,7 @@ module.exports = async (req, res) => {
currency: user.currency,
confirmed: true,
hash: "Internal Transfer",
- network: "COINOS",
+ network: "COINOS"
},
{ transaction }
);
@@ -52,18 +52,18 @@ module.exports = async (req, res) => {
res.send(payment);
user = await db.User.findOne({
- where: { username },
+ where: { username }
});
let params = {
user_id: user.id,
- asset,
+ asset
};
account = await db.Account.findOne({
where: params,
lock: transaction.LOCK.UPDATE,
- transaction,
+ transaction
});
if (account) {
@@ -79,6 +79,21 @@ module.exports = async (req, res) => {
if (assets[asset]) {
({ ticker, precision, name } = assets[asset]);
+ } else {
+ const existing = await db.Account.findOne({
+ where: {
+ asset
+ },
+ order: [["id", "ASC"]],
+ limit: 1
+ });
+
+ l.info("existing", existing);
+
+ if (existing) {
+ l.info(existing.name);
+ ({ ticker, precision, name } = existing);
+ }
}
params = { ...params, ...{ ticker, precision, name } };
@@ -97,7 +112,7 @@ module.exports = async (req, res) => {
confirmed: true,
hash: "Internal Transfer",
network: "COINOS",
- received: true,
+ received: true
},
{ transaction }
);