raspiblitz/home.admin/BBcloseAllChannels.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

2018-08-08 17:36:04 +02:00
#!/bin/bash
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
2018-08-09 13:18:06 +02:00
command="lncli closeallchannels --force"
2018-08-08 17:36:04 +02:00
clear
echo "***********************************"
echo "Closing All Channels (EXPERIMENTAL)"
echo "***********************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync
chainInSync=$(lncli getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
# execute command
if [ ${#command} -gt 0 ]; then
2018-08-09 13:16:53 +02:00
${command}
2018-08-08 17:36:04 +02:00
fi
echo ""
2018-08-09 13:26:44 +02:00
echo "OK"
2018-08-09 13:16:53 +02:00
sleep 2
2018-08-09 13:26:44 +02:00
2018-08-21 04:17:08 +02:00
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | grep chan_id -c)
2018-08-09 13:26:44 +02:00
if [ ${openChannels} -gt 0 ]; then
echo ""
echo "*******************"
echo "OK All Channels are closed now."
echo "You can now switch test/main or update RaspiBlitz safely, as long as you got your CIPHER WORD LIST SEED."
echo "*******************"
else
echo "!! WARNING you still have open channels:"
lnchannels
fi