aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routes/liquid/receive.js4
-rw-r--r--routes/payments.js92
2 files changed, 45 insertions, 51 deletions
diff --git a/routes/liquid/receive.js b/routes/liquid/receive.js
index e624c53a..f3b8397f 100644
--- a/routes/liquid/receive.js
+++ b/routes/liquid/receive.js
@@ -11,11 +11,13 @@ import zmq from "zeromq/v5-compat";
import { Op } from "@sequelize/core";
import { fromBase58 } from "bip32";
import bitcoin from "bitcoinjs-lib";
-import { Block, networks, Transaction } from "liquidjs-lib";
+import liquidJs from "liquidjs-lib";
import { l, err, warn } from "$lib/logging";
import lq from "$lib/liquid";
import { getUser } from "$lib/utils";
+const { Block, networks, Transaction } = liquidJs;
+
const network =
networks[
config.liquid.network === "mainnet" ? "liquid" : config.liquid.network
diff --git a/routes/payments.js b/routes/payments.js
index 6d4076cf..3e91e5fd 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -17,6 +17,10 @@ import btcRoutes from "./bitcoin/index";
import lnRoutes from "./lightning/index";
import lqRoutes from "./liquid/index";
+import "./bitcoin/receive";
+import "./lightning/receive";
+import "./liquid/receive";
+
app.post("/send", auth, send);
app.post("/sendToTokenHolders", auth, async (req, res, next) => {
let { asset, amount } = req.body;
@@ -31,12 +35,9 @@ app.post("/sendToTokenHolders", auth, async (req, res, next) => {
});
let totalTokens = accounts.reduce((a, b) => a + b.balance, 0);
- console.log("TOTAL TOKENS", totalTokens);
let totalSats = Math.floor(amount / totalTokens);
- console.log("TOTAL SATS", totalSats);
-
if (totalSats < 1) throw new Error("amount is too low to distribute");
for (let i = 0; i < accounts.length; i++) {
@@ -55,58 +56,49 @@ app.get("/except", adminAuth, (req, res) => {
res.send("updated exceptions");
});
-if (config.lna) {
- app.post("/lightning/channel", lnRoutes.channel);
- app.post("/lightning/invoice", lnRoutes.invoice);
- app.post("/lightning/query", auth, lnRoutes.query);
- app.post("/lightning/send", auth, lnRoutes.send);
- import("./lightning/receive");
+app.post("/lightning/channel", lnRoutes.channel);
+app.post("/lightning/invoice", lnRoutes.invoice);
+app.post("/lightning/query", auth, lnRoutes.query);
+app.post("/lightning/send", auth, lnRoutes.send);
- // if (config.lnurl) {
- // let channelRequest = await import("$routes/lightning/channelRequest");
- // app.post("/lightning/channelRequest", channelRequest)
- // }
-}
+// if (config.lnurl) {
+// let channelRequest = await import("$routes/lightning/channelRequest");
+// app.post("/lightning/channelRequest", channelRequest)
+// }
-if (config.bitcoin) {
- app.post("/bitcoin/broadcast", optionalAuth, btcRoutes.broadcast);
- app.get("/bitcoin/generate", auth, btcRoutes.generate);
- app.post("/bitcoin/sweep", auth, btcRoutes.sweep);
- app.post("/bitcoin/fee", auth, btcRoutes.fee);
- app.post("/bitcoin/send", auth, btcRoutes.send);
- import("./bitcoin/receive");
+app.post("/bitcoin/broadcast", optionalAuth, btcRoutes.broadcast);
+app.get("/bitcoin/generate", auth, btcRoutes.generate);
+app.post("/bitcoin/sweep", auth, btcRoutes.sweep);
+app.post("/bitcoin/fee", auth, btcRoutes.fee);
+app.post("/bitcoin/send", auth, btcRoutes.send);
- setTimeout(async () => {
- try {
- const address = await bc.getNewAddress();
- const { hdkeypath } = await bc.getAddressInfo(address);
- const parts = hdkeypath.split("/");
- store.bcAddressIndex = parts[parts.length - 1].replace("'", "");
- } catch (e) {
- console.error(e);
- }
- }, 50);
-}
+setTimeout(async () => {
+ try {
+ const address = await bc.getNewAddress();
+ const { hdkeypath } = await bc.getAddressInfo(address);
+ const parts = hdkeypath.split("/");
+ store.bcAddressIndex = parts[parts.length - 1].replace("'", "");
+ } catch (e) {
+ console.error(e);
+ }
+}, 50);
-if (config.liquid) {
- app.post("/liquid/broadcast", optionalAuth, lqRoutes.broadcast);
- app.get("/liquid/generate", auth, lqRoutes.generate);
- // app.post("/liquid/fee", auth, lqRoutes.fee);
- app.post("/liquid/send", auth, lqRoutes.send);
- // app.post("/taxi", auth, lqRoutes.taxi);
- import("./liquid/receive");
+app.post("/liquid/broadcast", optionalAuth, lqRoutes.broadcast);
+app.get("/liquid/generate", auth, lqRoutes.generate);
+// app.post("/liquid/fee", auth, lqRoutes.fee);
+app.post("/liquid/send", auth, lqRoutes.send);
+// app.post("/taxi", auth, lqRoutes.taxi);
- setTimeout(async () => {
- try {
- const address = await lq.getNewAddress();
- const { hdkeypath } = await lq.getAddressInfo(address);
- const parts = hdkeypath.split("/");
- store.lqAddressIndex = parts[parts.length - 1].slice(0, -1);
- } catch (e) {
- warn("Problem getting liquid address index", e.message);
- }
- }, 50);
-}
+setTimeout(async () => {
+ try {
+ const address = await lq.getNewAddress();
+ const { hdkeypath } = await lq.getAddressInfo(address);
+ const parts = hdkeypath.split("/");
+ store.lqAddressIndex = parts[parts.length - 1].slice(0, -1);
+ } catch (e) {
+ warn("Problem getting liquid address index", e.message);
+ }
+}, 50);
app.get("/payments", auth, async (req, res) => {
if (!req.user.account_id) return res.send([]);