aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-06-05 01:14:56 -0400
committerAdam Soltys <[email protected]>2021-06-05 01:14:56 -0400
commit421accbfbc0a1add93f7704e657ae93f2d836b82 (patch)
tree16807bc65a82ca80c5878d81c1c8dd945e8fccc9 /routes
parent3bdd16bb7a757f33587c9ef5834fa47c1ee00210 (diff)
downloadcoinos-server-421accbfbc0a1add93f7704e657ae93f2d836b82.tar.gz
coinos-server-421accbfbc0a1add93f7704e657ae93f2d836b82.zip
bump address indices
Diffstat (limited to 'routes')
-rw-r--r--routes/bitcoin/send.js1
-rw-r--r--routes/invoices.js5
-rw-r--r--routes/liquid/send.js1
-rw-r--r--routes/users.js8
4 files changed, 12 insertions, 3 deletions
diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js
index f1814b08..cab79e06 100644
--- a/routes/bitcoin/send.js
+++ b/routes/bitcoin/send.js
@@ -7,6 +7,7 @@ module.exports = ah(async (req, res) => {
let { hex } = tx;
let fee = toSats(tx.fee);
+ if (fee < 0) throw new Error("fee cannot be negative");
const isChange = async address =>
(await bc.getAddressInfo(address)).ismine &&
diff --git a/routes/invoices.js b/routes/invoices.js
index 5ec56871..cc8549e1 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -28,7 +28,7 @@ app.post(
let { blindkey } = invoice;
if (liquidAddress) {
- l.info("conversion request detected", liquidAddress);
+ l.info("conversion request for", liquidAddress, invoice.text);
convert[invoice.text] = { address: liquidAddress, tx };
}
@@ -53,7 +53,8 @@ app.post(
invoice.network,
invoice.amount,
invoice.tip,
- invoice.currency
+ invoice.currency,
+ `${invoice.text.substr(0, 8)}..${invoice.text.substr(-6)}`,
);
if (!invoice.tip) invoice.tip = 0;
diff --git a/routes/liquid/send.js b/routes/liquid/send.js
index 0207baae..19b7344f 100644
--- a/routes/liquid/send.js
+++ b/routes/liquid/send.js
@@ -2,6 +2,7 @@ const btc = config.liquid.btcasset;
const lcad = config.liquid.cadasset;
sendLiquid = async ({ asset, amount, user, address, memo, tx, limit }) => {
+ if (amount > 10000000) throw new Error("Amount too large");
l.info("sending liquid", amount, address);
if (!tx) {
({ tx } = await liquidTx({
diff --git a/routes/users.js b/routes/users.js
index 44478c0a..09ba5d43 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -2,7 +2,6 @@ const axios = require("axios");
const bcrypt = require("bcrypt");
const jwt = require("jsonwebtoken");
const authenticator = require("otplib").authenticator;
-const textToImage = require("text-to-image");
const randomWord = require("random-words");
const getAccount = require("../lib/account");
const Sequelize = require("sequelize");
@@ -425,6 +424,10 @@ app.get(
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);
+
app.set("bcAddressIndex", i + 1);
} else if (network === "liquid") {
p = liquid.payments;
@@ -435,6 +438,9 @@ app.get(
: config.liquid.network
];
type = "p2sh";
+
+ // async request to node to bump its internal index but don't use result
+ lq.getNewAddress().catch(console.error);
i = parseInt(app.get("lqAddressIndex"));
hd = fromBase58(config.liquid.masterkey, n).derivePath(`m/0'/0'/${i}'`);