aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js2
-rw-r--r--lib/binance.js1
-rw-r--r--routes/swaps.js68
-rw-r--r--routes/users.js48
4 files changed, 27 insertions, 92 deletions
diff --git a/index.js b/index.js
index a84df00d..4c567bbf 100644
--- a/index.js
+++ b/index.js
@@ -69,7 +69,7 @@ app.use((err, req, res, next) => {
if (req.user) details.username = req.user.username;
- l.error("Error: ", details);
+ // l.error("Error: ", details);
res.status(500);
res.set({
"Cache-Control": "no-cache"
diff --git a/lib/binance.js b/lib/binance.js
index db45ff6c..98fdd098 100644
--- a/lib/binance.js
+++ b/lib/binance.js
@@ -19,7 +19,6 @@ module.exports = () => {
app.set("bid", msg.b);
app.set("last", msg.c);
app.set("rates", rates);
- checkQueue();
} catch (e) {
l.error("binance socket error", e.message);
}
diff --git a/routes/swaps.js b/routes/swaps.js
index 21551f9e..5205d2ad 100644
--- a/routes/swaps.js
+++ b/routes/swaps.js
@@ -660,74 +660,6 @@ app.post(
})
);
-checkQueue = async () => {
- const ws = app.get("ws");
- const txs = [];
-
- leveldb
- .createReadStream()
- .on("data", async function(data) {
- txs.push({ ...JSON.parse(data.value), key: data.key });
- })
- .on("end", async function(data) {
- const rate = (a, b) => a.rate - b.rate;
- const time = (a, b) => b.time - a.time;
-
- const pending = txs.filter(tx => !tx.id);
- const completed = txs.filter(tx => tx.id).sort(time);
-
- const bitcoin = pending
- .filter(tx => tx.asset === "bitcoin")
- .sort(rate)
- .reverse();
- const tether = pending
- .filter(tx => tx.asset === "tether")
- .sort(rate)
- .reverse();
-
- const strip = a =>
- a.map(({ id, key, info, rate, time }) => ({
- id,
- key,
- info,
- rate,
- time
- }));
-
- ws &&
- ws.send(
- JSON.stringify({
- completed: strip(completed.slice(0, 3)),
- bitcoin: strip(bitcoin.slice(0, 3)),
- tether: strip(tether.slice(0, 3))
- })
- );
-
- let b, t, tx;
- if (bitcoin[0]) b = bitcoin[0].rate - app.get("ask");
- if (tether[0]) t = tether[0].rate - 1 / app.get("bid");
-
- if (b > 0 || t > 0) {
- if ((b && !t) || b > t) tx = bitcoin[0];
- if ((t && !b) || t > b) tx = tether[0];
- }
-
- if (tx) {
- try {
- tx.id = JSON.parse(await finalize(tx.text)).txid;
- tx.time = Date.now();
- delete tx.text;
- leveldb.put(tx.key, JSON.stringify(tx));
- } catch (e) {
- l.info(e);
- if (e.includes("Unexpected fees")) leveldb.del(tx.key);
- if (e.includes("unsigned inputs")) leveldb.del(tx.key);
- if (e.includes("insufficient fee")) leveldb.del(tx.key);
- }
- }
- });
-};
-
const parse = info => {
const fee = info.legs[0].fee;
return [
diff --git a/routes/users.js b/routes/users.js
index 73d7d7fe..77ae34f4 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -306,31 +306,26 @@ app.post(
app.post(
"/login",
ah(async (req, res) => {
- const { params, sig, key } = req.body;
+ try {
+ const { params, sig, key } = req.body;
- if (sig) {
- const { callback } = params;
+ if (sig) {
+ const { callback } = params;
- try {
- const url = `${callback}&sig=${sig}&key=${key}`;
- const response = await axios.get(url);
- res.send(response.data);
- } catch (e) {
- l.error("problem calling lnurl login", e.message);
- res.status(500).send(e.message);
- }
+ try {
+ const url = `${callback}&sig=${sig}&key=${key}`;
+ const response = await axios.get(url);
+ res.send(response.data);
+ } catch (e) {
+ l.error("problem calling lnurl login", e.message);
+ res.status(500).send(e.message);
+ }
- return;
- }
+ return;
+ }
- let twofa = req.body.token;
- l.info(
- "login",
- req.body.username,
- req.headers["x-forwarded-for"] || req.connection.remoteAddress
- );
+ let twofa = req.body.token;
- try {
let user = await getUser(req.body.username);
if (
@@ -354,6 +349,12 @@ app.post(
return res.status(401).send("2fa required");
}
+ l.info(
+ "login",
+ req.body.username,
+ req.headers["x-forwarded-for"] || req.connection.remoteAddress
+ );
+
let payload = { username: user.username };
let token = jwt.sign(payload, config.jwt);
res.cookie("token", token, { expires: new Date(Date.now() + 432000000) });
@@ -362,7 +363,7 @@ app.post(
user = pick(user, ...whitelist);
res.send({ user, token });
} catch (e) {
- l.error("login error", e.message);
+ // l.error("login error", e.message);
res.status(401).end();
}
})
@@ -467,7 +468,10 @@ app.get(
blindkey: blindkey.publicKey
}));
- lq.importBlindingKey(confidentialAddress, blindkey.privateKey.toString('hex'));
+ lq.importBlindingKey(
+ confidentialAddress,
+ blindkey.privateKey.toString("hex")
+ );
} else {
({ address } = p[type]({
redeem: p.p2wpkh({