aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/users.js')
-rw-r--r--routes/users.js108
1 files changed, 0 insertions, 108 deletions
diff --git a/routes/users.js b/routes/users.js
index 61d5d33a..3063758d 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -360,114 +360,6 @@ app.post("/logout", optionalAuth, async (req, res) => {
res.send({});
});
-app.get("/address", async (req, res) => {
- let { network, type } = req.query;
- let address, confidentialAddress;
-
- let paymentType = {
- bech32: "p2wpkh",
- "p2sh-segwit": "p2sh",
- legacy: "p2pkh",
- }[type];
- if (!paymentType) paymentType = "p2wpkh";
-
- let hd, i, p, n;
- const mutex = new Mutex();
- const release = await mutex.acquire();
- try {
- if (network === "bitcoin") {
- if (!config.bitcoin) return res.code(500).send("Bitcoin not configured");
-
- address = await bc.getNewAddress("", type);
- store.bcAddressIndex = i + 1;
- return res.send({ address });
-
- p = bitcoin.payments;
- n = prod ? bitcoin.networks["bitcoin"] : bitcoin.networks["regtest"];
-
- i = parseInt(store.bcAddressIndex);
- hd = fromBase58(config.bitcoin.masterkey, n).derivePath(`m/0'/0'/${i}'`);
-
- // async request to node to bump its internal index but don't use result
- bc.getNewAddress().catch(console.error);
- res.send({ address, confidentialAddress });
-
- store.bcAddressIndex = i + 1;
- } else if (network === "liquid") {
- p = liquid.payments;
- n =
- liquid.networks[
- config.liquid.network === "mainnet" ? "liquid" : config.liquid.network
- ];
- paymentType = "p2sh";
-
- // async request to node to bump its internal index but don't use result
- lq.getNewAddress().catch((e) =>
- warn("Problem bumping liquid address index", e.message)
- );
-
- i = parseInt(store.lqAddressIndex);
-
- if (!i) {
- const { hdkeypath } = await lq.getAddressInfo(await lq.getNewAddress());
- const parts = hdkeypath.split("/");
- i = parseInt(parts[parts.length - 1].slice(0, -1));
- }
-
- l("liquid address index", i);
- if (!i) throw new Error("Problem generating address");
-
- hd = fromBase58(config.liquid.masterkey, n).derivePath(`m/0'/0'/${i}'`);
- store.lqAddressIndex = i + 1;
- } else {
- throw new Error("Unsupported network");
- }
- } finally {
- release();
- }
-
- if (paymentType !== "p2sh") {
- ({ address } = p[paymentType]({
- pubkey: hd.publicKey,
- network: n,
- }));
- } else {
- if (network === "liquid") {
- const p2wpkh = p.p2wpkh({
- pubkey: hd.publicKey,
- network: n,
- });
-
- const blindkey = fromPrivateKey(
- Buffer.from(config.liquid.blindkey, "hex"),
- hd.chainCode,
- n
- );
-
- ({ address, confidentialAddress } = p[paymentType]({
- redeem: p2wpkh,
- network: n,
- blindkey: blindkey.publicKey,
- }));
-
- lq.importBlindingKey(
- confidentialAddress,
- blindkey.privateKey.toString("hex")
- );
- } else {
- ({ address } = p[paymentType]({
- redeem: p.p2wpkh({
- pubkey: hd.publicKey,
- network: n,
- }),
- network: n,
- }));
- }
- }
-
- res.send({ address, confidentialAddress });
-});
-
app.post("/account", auth, async (req, res) => {
const { user } = req;
const {