diff options
| author | Adam Soltys <[email protected]> | 2021-06-05 01:14:56 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-06-05 01:14:56 -0400 |
| commit | 421accbfbc0a1add93f7704e657ae93f2d836b82 (patch) | |
| tree | 16807bc65a82ca80c5878d81c1c8dd945e8fccc9 | |
| parent | 3bdd16bb7a757f33587c9ef5834fa47c1ee00210 (diff) | |
| download | coinos-server-421accbfbc0a1add93f7704e657ae93f2d836b82.tar.gz coinos-server-421accbfbc0a1add93f7704e657ae93f2d836b82.zip | |
bump address indices
| -rw-r--r-- | index.js | 7 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | routes/bitcoin/send.js | 1 | ||||
| -rw-r--r-- | routes/invoices.js | 5 | ||||
| -rw-r--r-- | routes/liquid/send.js | 1 | ||||
| -rw-r--r-- | routes/users.js | 8 | ||||
| -rwxr-xr-x | watcher.sh | 11 |
7 files changed, 21 insertions, 13 deletions
@@ -70,7 +70,6 @@ require("./lib/notifications"); require("./lib/register"); require("./lib/send"); -require("./lib/mail"); require("./routes/assets"); require("./routes/invoices"); @@ -80,9 +79,9 @@ require("./routes/swaps"); require("./routes/users"); require("./routes/funding"); -if (config.lnurl) { - require("./routes/lnurl"); -} +if (config.lnurl) require("./routes/lnurl"); +if (config.imap) require("./lib/mail"); + const sigHeaderName = "X-Hub-Signature-256"; const sigHashAlg = "sha256"; diff --git a/package.json b/package.json index aef8bfc9..ae280704 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "request": "~2.88.0", "sequelize": "^5.21.3", "sqlite3": "^5.0.0", - "text-to-image": "^2.3.0", "uuid": "^3.3.2", "web-push": "^3.4.4", "ws": "^7.1.2", 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}'`); @@ -1,19 +1,20 @@ #!/bin/bash sats=100000000 +threshold=$1 while true do ln=$(lncli --lnddir=/root/.lnda --network=mainnet --chain=bitcoin --rpcserver=localhost:10001 channelbalance | jr .balance) bc=$(bitcoin-cli getbalance) el=$(elements-cli getbalance | jr .bitcoin) total=$(node -pe "$ln + $bc * $sats + $el * $sats") - low=$(node -pe "$total < $1") + low=$(node -pe "$total < $threshold") echo $(date -Is) ln $ln bc $bc el $el tot $total if "$low"; then - echo "Balance below threshold, shutting down" - yarn pm2 stop 0 > /dev/null - cd /root/mailgun && node index.js - exit + echo "Threshold hit, setting new threshold" + threshold=$total + # yarn pm2 stop 0 > /dev/null + node /root/mailgun/index.js fi sleep 10 done |
