aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/rpc.js11
-rw-r--r--lib/sockets.js6
-rw-r--r--prod.yml2
-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
8 files changed, 28 insertions, 13 deletions
diff --git a/lib/rpc.js b/lib/rpc.js
index 366e1e70..3e217c7e 100644
--- a/lib/rpc.js
+++ b/lib/rpc.js
@@ -5,9 +5,10 @@ export default ({ host, port, wallet, username, password }) =>
{},
{
get: (target, prop) => (...params) =>
- ((method, ...params) =>
- wretch()
- .url(`http://${host}:${port}/wallet/${wallet}`)
+ ((method, ...params) => {
+ let url = `http://${host}:${port}/wallet/${wallet}`;
+ return wretch()
+ .url(url)
.auth(
`Basic ${Buffer.from(`${username}:${password}`).toString(
"base64"
@@ -17,6 +18,8 @@ export default ({ host, port, wallet, username, password }) =>
method,
params
})
- .json(({ result }) => result))(prop.toLowerCase(), ...params)
+ .json(({ result }) => result)
+ })(prop.toLowerCase(), ...params)
+
}
);
diff --git a/lib/sockets.js b/lib/sockets.js
index ee16b962..33d1d208 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -90,8 +90,7 @@ app.register(async function(app) {
case "login":
let token = data;
-
- if (lastSeen[token] > subtractSeconds(5)) ws.close();
+ if (lastSeen[token] > subtractSeconds(5)) return;
lastSeen[token] = new Date();
try {
@@ -136,6 +135,7 @@ app.register(async function(app) {
});
let accounts = await user.getAccounts();
+
let keys = await user.getKeys();
user = user.get({ plain: true });
user.accounts = accounts;
@@ -194,7 +194,7 @@ app.register(async function(app) {
});
ws.on("close", function(code, reason) {
- // if (reason) console.log("closing socket", reason);
+ // if (reason) console.log("closing socket", reason.toString(), id);
try {
const username = names[id];
if (store.sockets[username] && store.sockets[username][id]) {
diff --git a/prod.yml b/prod.yml
index 5453e651..c77c129e 100644
--- a/prod.yml
+++ b/prod.yml
@@ -12,6 +12,8 @@ services:
- ./:/app
- ./logs:/logs
- /root/.lnda/tls.cert:/tls.cert
+ extra_hosts:
+ - host.docker.internal:host-gateway
maria:
container_name: maria
image: mariadb
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) {