aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-01-15 18:35:05 -0500
committerAdam Soltys <[email protected]>2021-01-17 02:25:12 -0500
commit5f7a63c72883590c2fa538c5942064e6f6a13b09 (patch)
tree7f97749fc910e6c02a35ba2adfb9713f8d3a7b8f
parentd9e10940710fbc631411dc66979410b95f084052 (diff)
downloadcoinos-server-5f7a63c72883590c2fa538c5942064e6f6a13b09.tar.gz
coinos-server-5f7a63c72883590c2fa538c5942064e6f6a13b09.zip
script to watch balance
-rw-r--r--.gitignore1
-rwxr-xr-xwatcher.sh18
2 files changed, 19 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index c828b556..0ce09c75 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ uploads
verified
data
lnurl-server.sqlite3
+watcher.log
diff --git a/watcher.sh b/watcher.sh
new file mode 100755
index 00000000..74451bf6
--- /dev/null
+++ b/watcher.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+sats=100000000
+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")
+ 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
+ exit
+ fi
+ sleep 10
+done