Browse Source

updated to new config and added more edge case info

#146
rootzoll 6 years ago
parent
commit
3b7d7748fa
  1. 38
      home.admin/BBcashoutWallet.sh
  2. 19
      home.admin/BBcloseAllChannels.sh

38
home.admin/BBcashoutWallet.sh

@ -2,17 +2,39 @@
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
# load raspiblitz config data (with backup from old config)
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
fi
# get available amount in on-chain wallet
maxAmount=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
# check if user has money in lightning channels - info about close all
openChannels=$(lncli --chain=${network} listchannels 2>/dev/null | jq '.[] | length')
if [ ${#openChannels} -eq 0 ]; then
echo "*** IMPORTANT **********************************"
echo "It looks like LND is not responding."
echo "Still starting up, is locked or is not running?"
echo "Try later, try reboot or check ./XXdebugLogs.sh"
echo "************************************************"
exit 1
fi
if [ ${openChannels} -gt 0 ]; then
dialog --title 'Info' --msgbox 'You still have funds in open Lightning Channels.\nUse CLOSEALL first if you want to cashout all funds.\nNOTICE: Just confirmed on-chain funds can be moved.' 7 58
fi
# TODO: pre-check if channels are open or are still in closing
# and let user know not all funds are available yet (just info Dialoge)
# check if money is waiting to get confirmed
unconfirmed=$(lncli --chain=${network} walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
if [ ${unconfirmed} -gt 0 ]; then
dialog --title 'Info' --msgbox "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58
fi
# TODO: pre-check user hast more than 0 sat in on-chain wallet to send
# get available amount in on-chain wallet
maxAmount=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
if [ ${maxAmount} -gt 0 ]; then
dialog --title 'Info' --msgbox "You have 0 moveable funds available.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58
exit 1
fi
# let user enter the amount
l1="Enter the amount of funds you want to send/remove:"

19
home.admin/BBcloseAllChannels.sh

@ -1,19 +1,18 @@
#!/bin/bash
source /mnt/hdd/raspiblitz.conf
# load raspiblitz config data (with backup from old config)
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
fi
# precheck: AutoPilot
if [ "${autoPilot}" = "on" ]; then
echo "*** IMPORTANT **********************************"
echo "You need to turn OFF the LND AutoPilot first,"
echo "so that closed channels are not opening up again."
echo "You find the AutoPilot -----> SERVICES section"
echo "************************************************"
dialog --title 'Info' --msgbox 'You need to turn OFF the LND AutoPilot first,\nso that closed channels are not opening up again.\nYou find the AutoPilot -----> SERVICES section' 7 55
exit 1
fi
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli --chain=${network} closeallchannels --force"
clear

Loading…
Cancel
Save