aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-08-03 01:52:33 -0700
committerAdam Soltys <[email protected]>2021-08-03 01:52:33 -0700
commite5e2bcf015b128c71cacf125d6aea4a0dddd30c3 (patch)
tree09af4085f72fa2466cb0f66768be6e882be30f81 /routes/users.js
parent2f52a91c5babde9e374dd9c532448f565bcbfeee (diff)
parent1fbae57bb9540b1c116efc367809ac01ae2e9df2 (diff)
downloadcoinos-server-e5e2bcf015b128c71cacf125d6aea4a0dddd30c3.tar.gz
coinos-server-e5e2bcf015b128c71cacf125d6aea4a0dddd30c3.zip
Merge branch 'prod' into dev
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 {