aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-08 17:03:45 -0400
committerAdam Soltys <[email protected]>2022-09-08 17:03:45 -0400
commit5a552347b012cdebf1b5bc4834d650a1e97bfd3d (patch)
treef3acf6ab6205c18a44fe88528ad797006a63666f /routes
parente36990c368d991e7cd52be874ad200fc3bc7205a (diff)
downloadcoinos-server-5a552347b012cdebf1b5bc4834d650a1e97bfd3d.tar.gz
coinos-server-5a552347b012cdebf1b5bc4834d650a1e97bfd3d.zip
misc fixes
Diffstat (limited to 'routes')
-rw-r--r--routes/assets.js4
-rw-r--r--routes/bitcoin/receive.js4
-rw-r--r--routes/info.js5
-rw-r--r--routes/lightning/invoice.js4
-rw-r--r--routes/users.js5
5 files changed, 16 insertions, 6 deletions
diff --git a/routes/assets.js b/routes/assets.js
index 8140b179..53e89602 100644
--- a/routes/assets.js
+++ b/routes/assets.js
@@ -18,9 +18,9 @@ let fetchAssets;
store.assets = data;
} catch (e) {
- var liquid_assets = require("./../assets.json");
+ var liquid_assets = JSON.parse(fs.readFileSync("/app/assets.json"));
if (liquid_assets) {
- app.set("assets", liquid_assets);
+ store.assets = liquid_assets;
console.debug("using static assets..." + e.message);
} else {
err("error fetching assets", e.message);
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js
index 07266d5f..7fc685c5 100644
--- a/routes/bitcoin/receive.js
+++ b/routes/bitcoin/receive.js
@@ -159,6 +159,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => {
});
zmqRawBlock.on("message", async (topic, message, sequence) => {
+ try {
const payments = await db.Payment.findAll({
where: { confirmed: false }
});
@@ -168,6 +169,9 @@ zmqRawBlock.on("message", async (topic, message, sequence) => {
let hash = reverse(tx.getHash()).toString("hex");
if (payments.find(p => p.hash === hash)) queue[hash] = 1;
});
+ } catch(e) {
+ console.log(e)
+ }
});
setInterval(async () => {
diff --git a/routes/info.js b/routes/info.js
index c7d39160..63f353a5 100644
--- a/routes/info.js
+++ b/routes/info.js
@@ -9,6 +9,7 @@ import lnd from "$lib/lnd";
import { getChannelBalance, getChainBalance } from "lightning";
import sequelize from "@sequelize/core";
+import { SATS } from "$lib/utils";
const { Op } = sequelize;
@@ -34,6 +35,7 @@ app.get("/info", async (req, res, next) => {
});
app.get("/balances", async (req, res, next) => {
+ try {
const accounts = await db.Account.findAll({
attributes: [
"asset",
@@ -90,4 +92,7 @@ app.get("/balances", async (req, res, next) => {
parseInt(lnwallet);
res.send(info);
+ } catch(e) {
+ console.log("problem getting balances", e)
+ }
});
diff --git a/routes/lightning/invoice.js b/routes/lightning/invoice.js
index 05ec7e09..3ef0e109 100644
--- a/routes/lightning/invoice.js
+++ b/routes/lightning/invoice.js
@@ -8,6 +8,7 @@ export default async (req, res) => {
if (!tip) tip = 0;
let value = amount + tip;
+ console.log("getting invoice");
try {
if (config.lna.clightning) {
if (!memo) memo = "coinos";
@@ -19,14 +20,17 @@ export default async (req, res) => {
);
res.send({ text: invoice.bolt11 });
} else {
+ console.log("creating invoice");
const invoice = await createInvoice({
lnd,
tokens: value,
description: memo
});
+ console.log("created");
res.send({ text: invoice.request });
}
} catch (e) {
+ console.log(e)
err("problem creating invoice", e.message);
res.code(500).send(e.message);
}
diff --git a/routes/users.js b/routes/users.js
index ac7001d2..60f88562 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -10,7 +10,7 @@ import { authenticator } from "otplib";
import getAccount from "$lib/account";
import Sequelize from "@sequelize/core";
import bitcoin from "bitcoinjs-lib";
-// import liquid from "liquidjs-lib";
+import liquid from "liquidjs-lib";
import { fromBase58, fromPrivateKey } from "bip32";
import { Mutex } from "async-mutex";
import bip32 from "bip32";
@@ -293,11 +293,8 @@ let login = async (req, res) => {
if (sig) {
const { callback } = params;
- console.log(params, sig, key)
-
try {
const url = `${callback}&sig=${sig}&key=${key}`;
- console.log(url)
const response = await axios.get(url);
res.send(response.data);
} catch (e) {