aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-08-09 20:55:17 -0700
committerAdam Soltys <[email protected]>2021-08-09 20:55:17 -0700
commit56559c7b9749fe62fe2fe0ba90725391d83b8bf7 (patch)
tree48d6a0630d05d6787b4410708a5efceff472636b /routes/users.js
parent803ecab2b5c3a00d107372ea6757cd6ce0f8224d (diff)
parent8d6f65079868ae6134f593752e3380180591623d (diff)
downloadcoinos-server-56559c7b9749fe62fe2fe0ba90725391d83b8bf7.tar.gz
coinos-server-56559c7b9749fe62fe2fe0ba90725391d83b8bf7.zip
Merge branch 'v1.0.0'
Diffstat (limited to 'routes/users.js')
-rw-r--r--routes/users.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/routes/users.js b/routes/users.js
index 71f4b89a..23f016c7 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -148,7 +148,8 @@ app.post(
return res.status(500).send("Username taken");
} else {
sockets[username] = sockets[user.username];
- if (user.username !== username) l.info("changing username", user.username, username);
+ if (user.username !== username)
+ l.info("changing username", user.username, username);
user.username = username;
token = jwt.sign({ username }, config.jwt);
@@ -323,10 +324,7 @@ app.post(
(user.password &&
!(await bcrypt.compare(req.body.password, user.password)))
) {
- l.warn(
- "invalid username or password attempt",
- req.body.username
- );
+ l.warn("invalid username or password attempt", req.body.username);
return res.status(401).end();
}
@@ -426,11 +424,24 @@ app.get(
: config.liquid.network
];
type = "p2sh";
-
+
// async request to node to bump its internal index but don't use result
- lq.getNewAddress().catch(console.error);
+ lq.getNewAddress().catch(e =>
+ l.warn("Problem bumping liquid address index", e.message)
+ );
i = parseInt(app.get("lqAddressIndex"));
+
+ if (!i) {
+ const { hdkeypath } = await lq.getAddressInfo(
+ await lq.getNewAddress()
+ );
+ const parts = hdkeypath.split("/");
+ i = parts[parts.length - 1].slice(0, -1);
+ }
+
+ if (!i) throw new Error("Problem generating address");
+
hd = fromBase58(config.liquid.masterkey, n).derivePath(`m/0'/0'/${i}'`);
app.set("lqAddressIndex", i + 1);
} else {