aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js1
-rw-r--r--lib/sockets.js4
-rw-r--r--routes/invoices.js2
-rw-r--r--routes/users.js17
4 files changed, 21 insertions, 3 deletions
diff --git a/index.js b/index.js
index c03936f2..bd09ae1b 100644
--- a/index.js
+++ b/index.js
@@ -66,7 +66,6 @@ app.use((err, req, res, next) => {
if (req.user) details.username = req.user.username;
l.error("Error: ", err.message);
- throw err;
res.status(500);
res.send(err.message);
return res.end();
diff --git a/lib/sockets.js b/lib/sockets.js
index 117a8d67..9e683e0c 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -11,10 +11,11 @@ const subscriptions = [];
emit = (username, type, data) => {
if (data.username !== undefined) data = pick(data, ...whitelist);
+ l.info("msg", data);
if (type === "payment" && data.amount > 0) {
for (let i = subscriptions.length - 1; i >= 0; i--) {
let s = subscriptions[i];
- if (s.invoice.amount === data.amount) {
+ if (s.invoice.amount === data.amount || s.invoice.address === data.address || s.invoice.unconfidential === data.address) {
s.ws.send(JSON.stringify({ type, data }));
subscriptions.splice(i, 1);
}
@@ -134,6 +135,7 @@ wss.on("connection", function (ws, req) {
}
break;
case "subscribe":
+ l.info("subscribe", data.amount);
subscriptions.push({ invoice: data, ws });
break;
default:
diff --git a/routes/invoices.js b/routes/invoices.js
index f344e9f9..ba4da254 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -29,6 +29,7 @@ app.post("/invoice", ah(async (req, res, next) => {
l.info(
"creating invoice",
+ invoice.address,
invoice.text,
user.username,
invoice.network,
@@ -55,5 +56,6 @@ app.post("/invoice", ah(async (req, res, next) => {
invoice = exists ? await exists.update(invoice) : await db.Invoice.create(invoice);
addresses[invoice.address] = user.username;
+ if (invoice.unconfidential) addresses[invoice.unconfidential] = user.username;
res.send(invoice);
}));
diff --git a/routes/users.js b/routes/users.js
index 471a4e5e..99dd6046 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -297,12 +297,27 @@ app.post(
app.get(
"/address",
ah(async (req, res) => {
+ const { network, type } = req.query;
+ let address;
+
+ if (network === 'bitcoin') {
if (!config.bitcoin) return res.status(500).send("Bitcoin not configured");
if (config.bitcoin.walletpass)
await bc.walletPassphrase(config.bitcoin.walletpass, 300);
- res.send(await bc.getNewAddress("", req.query.type || "bech32"));
+ address = await bc.getNewAddress("", type || "bech32");
+ } else if (network === 'liquid') {
+
+ if (!config.liquid) return res.status(500).send("Liquid not configured");
+
+ if (config.liquid.walletpass)
+ await lq.walletPassphrase(config.liquid.walletpass, 300);
+
+ address = await lq.getNewAddress("", type || "bech32");
+ }
+
+ res.send(address);
})
);