fix txindex and wallet script

This commit is contained in:
Robert Habermann
2020-01-03 13:51:09 +00:00
parent da84ee0ad9
commit ce0b295459
2 changed files with 55 additions and 13 deletions

View File

@@ -3,19 +3,30 @@
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch txindex on or off" echo "config script to switch txindex on or off"
echo "network.txindex.sh [on|off]" echo "network.txindex.sh [status|on|off]"
exit 1 exit 1
fi fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
source /mnt/hdd/${network}/${network}.conf
# add default value to bitcoin.conf if needed # add txindex with default value (0) to bitcoin.conf if missing
if [ ${#txindex} -eq 0 ]; then if ! grep -Eq "^txindex=.*" /mnt/hdd/${network}/${network}.conf; then
echo "txindex=0" >> /mnt/hdd/${network}/${network}.conf echo "txindex=0" | sudo tee -a /mnt/hdd/${network}/${network}.conf >/dev/null
source /mnt/hdd/${network}/${network}.conf
fi fi
# set variable ${txindex}
source <(grep -E "^txindex=.*" /mnt/hdd/${network}/${network}.conf)
# check for testnet and set pathAdd (e.g. for debug.log)
pathAdd=""
if [ "${chain}" = "test" ]; then
pathAdd="/testnet3"
fi
###################
# STATUS
###################
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
echo "##### STATUS TXINDEX" echo "##### STATUS TXINDEX"
@@ -26,9 +37,9 @@ if [ "$1" = "status" ]; then
fi fi
# try to gather if still indexing # try to gather if still indexing
indexedToBlock=$(sudo tail -n 100 /mnt/hdd/${network}/debug.log | grep "Syncing txindex with block chain from height" | tail -n 1 | cut -d " " -f 9 | sed 's/[^0-9]*//g') indexedToBlock=$(sudo tail -n 200 /mnt/hdd/${network}${pathAdd}/debug.log | grep "Syncing txindex with block chain from height" | tail -n 1 | cut -d " " -f 9 | sed 's/[^0-9]*//g')
blockchainHeight=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | jq -r '.blocks' | sed 's/[^0-9]*//g') blockchainHeight=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | jq -r '.blocks' | sed 's/[^0-9]*//g')
indexFinished=$(sudo tail -n 100 /mnt/hdd/${network}/debug.log | grep -c "txindex is enabled at height") indexFinished=$(sudo tail -n 200 /mnt/hdd/${network}${pathAdd}/debug.log | grep -c "txindex is enabled at height")
echo "indexedToBlock=${indexedToBlock}" echo "indexedToBlock=${indexedToBlock}"
echo "blockchainHeight=${blockchainHeight}" echo "blockchainHeight=${blockchainHeight}"
echo "indexFinished=${indexFinished}" echo "indexFinished=${indexFinished}"
@@ -48,14 +59,17 @@ if [ "$1" = "status" ]; then
fi fi
###################
# switch on # switch on
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ ${txindex} == 0 ]; then if [ ${txindex} == 0 ]; then
sudo sed -i "s/^txindex=.*/txindex=1/g" /mnt/hdd/${network}/${network}.conf sudo sed -i "s/^txindex=.*/txindex=1/g" /mnt/hdd/${network}/${network}.conf
echo "switching txindex=1 and restarting ${network}d" echo "switching txindex=1 and restarting ${network}d"
sudo systemctl restart ${network}d sudo systemctl restart ${network}d
echo "The indexing takes ~7h on an RPi4 with SSD" echo "The indexing takes ~7h on an RPi4 with SSD"
echo "monitor with: sudo tail -n 20 -f /mnt/hdd/${network}/debug.log" echo "monitor with: sudo tail -n 20 -f /mnt/hdd/${network}${pathAdd}/debug.log"
exit 0 exit 0
else else
echo "txindex is already active" echo "txindex is already active"
@@ -63,7 +77,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi fi
fi fi
###################
# switch off # switch off
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo sed -i "s/^txindex=.*/txindex=0/g" /mnt/hdd/${network}/${network}.conf sudo sed -i "s/^txindex=.*/txindex=0/g" /mnt/hdd/${network}/${network}.conf
sudo systemctl restart ${network}d sudo systemctl restart ${network}d
@@ -71,4 +88,4 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
fi fi
echo "FAIL - Unknown Parameter $1" echo "FAIL - Unknown Parameter $1"
exit 1 exit 1

View File

@@ -3,14 +3,36 @@
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch the Bitcoin Core wallet on or off" echo "config script to switch the Bitcoin Core wallet on or off"
echo "network.wallet.sh [on|off]" echo "network.wallet.sh [status|on|off]"
exit 1 exit 1
fi fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
source /mnt/hdd/${network}/${network}.conf
# add disablewallet with default value (0) to bitcoin.conf if missing
if ! grep -Eq "^disablewallet=.*" /mnt/hdd/${network}/${network}.conf; then
echo "disablewallet=0" | sudo tee -a /mnt/hdd/${network}/${network}.conf >/dev/null
fi
# set variable ${disablewallet}
source <(grep -E "^disablewallet=.*" /mnt/hdd/${network}/${network}.conf)
###################
# STATUS
###################
if [ "$1" = "status" ]; then
echo "##### STATUS disablewallet"
echo "disablewallet=${disablewallet}"
exit 0
fi
###################
# switch on # switch on
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ ${disablewallet} == 1 ]; then if [ ${disablewallet} == 1 ]; then
sudo sed -i "s/^disablewallet=.*/disablewallet=0/g" /mnt/hdd/${network}/${network}.conf sudo sed -i "s/^disablewallet=.*/disablewallet=0/g" /mnt/hdd/${network}/${network}.conf
@@ -23,7 +45,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi fi
fi fi
###################
# switch off # switch off
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo sed -i "s/^disablewallet=.*/disablewallet=1/g" /mnt/hdd/${network}/${network}.conf sudo sed -i "s/^disablewallet=.*/disablewallet=1/g" /mnt/hdd/${network}/${network}.conf
sudo systemctl restart ${network}d sudo systemctl restart ${network}d
@@ -31,4 +56,4 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
fi fi
echo "FAIL - Unknown Parameter $1" echo "FAIL - Unknown Parameter $1"
exit 1 exit 1