diff options
| author | Adam Soltys <[email protected]> | 2023-07-13 08:05:08 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-08-09 07:31:48 +0000 |
| commit | 39128cfa7473bed42292ddd5f3016cd22b00f72a (patch) | |
| tree | b218fcd456c9942a5c4bd23cfc34a6e0fb7eed8f | |
| parent | 923947519e74e28ab57f600100ea6d540d3fd561 (diff) | |
| download | coinos-server-39128cfa7473bed42292ddd5f3016cd22b00f72a.tar.gz coinos-server-39128cfa7473bed42292ddd5f3016cd22b00f72a.zip | |
update watcher script
| -rw-r--r-- | routes/users.js | 1 | ||||
| -rwxr-xr-x | watcher.sh | 25 |
2 files changed, 18 insertions, 8 deletions
diff --git a/routes/users.js b/routes/users.js index 19cd88f5..3c8b2568 100644 --- a/routes/users.js +++ b/routes/users.js @@ -460,6 +460,7 @@ export default { let id = await g(`user:${username.toLowerCase().replace(/\s/g, "")}`); let user = await g(`user:${id}`); + user.pin = null; user.pubkey = null; user.cipher = null; user.salt = null; @@ -6,20 +6,29 @@ while true do f=/home/adam/coinos-server/data/funds/$(date +"%m-%d-%y-%T").json docker exec -it cl lightning-cli listfunds > $f + lnc=$(cat $f | jr '[.channels[] | select(.state == "CHANNELD_NORMAL") | .our_amount_msat] | add') + lnc=$(node -pe "((($lnc)/$sats)/1000).toFixed(4)") + lnw=$(cat $f | jr '[.outputs[] | .amount_msat] | add') - ln=$(node -pe "($lnc + $lnw)/1000") + lnw=$(node -pe "((($lnw)/$sats)/1000).toFixed(4)") + bc=$(docker exec -it bc bitcoin-cli getbalance | jr) - total=$(node -pe "$ln + $bc * $sats") + bc=$(node -pe "($bc).toFixed(4)") + + total=$(node -pe "($lnc + $lnw + $bc).toFixed(4)") + accts=$(curl -s https://coinos.io/api/balances | jr '.total') - gap=$(node -pe "$accts - $total") + accts=$(node -pe "($accts / $sats).toFixed(4)") + + gap=$(node -pe "($accts - $total).toFixed(4)") echo $(date -Is) lnc $lnc lnw $lnw bc $bc tot $total gap $gap low=$(node -pe "!!($gap > $threshold)") - if "$low"; then - echo "Threshold hit, setting new threshold" -# docker stop app; - curl localhost:3119/email -H "content-type: application/json" -d '{"token": "MPJzfq97ab!!!!", "message": "threshold hit"}' - fi +# if "$low"; then +# echo "Threshold hit, setting new threshold" +# # docker stop app; +# curl localhost:3119/email -H "content-type: application/json" -d '{"token": "MPJzfq97ab!!!!", "message": "threshold hit"}' +# fi sleep 120 done |
