aboutsummaryrefslogtreecommitdiffstats
path: root/watcher.sh
diff options
context:
space:
mode:
Diffstat (limited to 'watcher.sh')
-rwxr-xr-xwatcher.sh18
1 files changed, 18 insertions, 0 deletions
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