aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-08-03 22:38:36 -0700
committerAdam Soltys <[email protected]>2020-08-03 22:38:36 -0700
commitba07b04fbbf9de058907db50a01daebf2ff4d6bb (patch)
treeb3c6e78458c708c6b5789f394fcfde1979a8912b /routes
parent2bcd5e9cd2233934b6d78724a07172b187ceb0b0 (diff)
downloadcoinos-server-ba07b04fbbf9de058907db50a01daebf2ff4d6bb.tar.gz
coinos-server-ba07b04fbbf9de058907db50a01daebf2ff4d6bb.zip
handle liquid payments to user url
Diffstat (limited to 'routes')
-rw-r--r--routes/invoices.js2
-rw-r--r--routes/users.js17
2 files changed, 18 insertions, 1 deletions
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);
})
);