Browse Source

litecoin basics

#146
rootzoll 7 years ago
parent
commit
4467d2dd42
  1. 32
      home.admin/00infoBlitz.sh
  2. 35
      home.admin/00mainMenu.sh
  3. 55
      home.admin/10setupBlitz.sh
  4. 15
      home.admin/20initDialog.sh
  5. 2
      home.admin/40addHDD.sh
  6. 30
      home.admin/50copyHDD.sh
  7. 27
      home.admin/50downloadHDD.sh
  8. 40
      home.admin/50syncHDD.sh
  9. 33
      home.admin/60finishHDD.sh
  10. 52
      home.admin/70initLND.sh
  11. 11
      home.admin/80scanLND.sh
  12. 8
      home.admin/AAunlockLND.sh
  13. 25
      home.admin/XXcleanHDD.sh
  14. 28
      home.admin/assets/litecoin.conf
  15. 21
      home.admin/assets/lnd.litecoin.conf

32
home.admin/00infoBlitz.sh

@ -3,7 +3,7 @@
# /etc/systemd/system/20-raspibolt-welcome.sh # /etc/systemd/system/20-raspibolt-welcome.sh
# make executable and copy script to /etc/update-motd.d/ # make executable and copy script to /etc/update-motd.d/
# root must be able to execute bitcoin-cli and lncli # root must be able to execute network cli and lncli
# set colors # set colors
color_red='\033[0;31m' color_red='\033[0;31m'
@ -11,8 +11,11 @@ color_green='\033[0;32m'
color_yellow='\033[0;33m' color_yellow='\033[0;33m'
color_gray='\033[0;37m' color_gray='\033[0;37m'
# load network
network=`sudo cat /home/admin/.network`
# set datadir # set datadir
bitcoin_dir="/home/bitcoin/.bitcoin" bitcoin_dir="/home/bitcoin/.${network}"
lnd_dir="/home/bitcoin/.lnd" lnd_dir="/home/bitcoin/.lnd"
# get uptime & load # get uptime & load
@ -55,19 +58,19 @@ network_rx=$(ifconfig eth0 | grep 'RX packets' | awk '{ print $6$7 }' | sed 's/[
network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g') network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
# Bitcoin blockchain # Bitcoin blockchain
btc_path=$(command -v bitcoin-cli) btc_path=$(command -v ${network}-cli)
if [ -n ${btc_path} ]; then if [ -n ${btc_path} ]; then
btc_title="Bitcoin" btc_title=$network
chain="$(bitcoin-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.chain')" chain="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.chain')"
if [ -n $chain ]; then if [ -n $chain ]; then
btc_title="${btc_title} (${chain}net)" btc_title="${btc_title} (${chain}net)"
# get sync status # get sync status
block_chain="$(bitcoin-cli -datadir=${bitcoin_dir} getblockcount)" block_chain="$(${network}-cli -datadir=${bitcoin_dir} getblockcount)"
block_verified="$(bitcoin-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.blocks')" block_verified="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.blocks')"
block_diff=$(expr ${block_chain} - ${block_verified}) block_diff=$(expr ${block_chain} - ${block_verified})
progress="$(bitcoin-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.verificationprogress')" progress="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.verificationprogress')"
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')") sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
if [ ${block_diff} -eq 0 ]; then # fully synced if [ ${block_diff} -eq 0 ]; then # fully synced
@ -89,13 +92,13 @@ if [ -n ${btc_path} ]; then
fi fi
# get last known block # get last known block
last_block="$(bitcoin-cli -datadir=${bitcoin_dir} getblockcount)" last_block="$(${network}-cli -datadir=${bitcoin_dir} getblockcount)"
if [ ! -z "${last_block}" ]; then if [ ! -z "${last_block}" ]; then
btc_line2="${btc_line2} ${color_gray}(block ${last_block})" btc_line2="${btc_line2} ${color_gray}(block ${last_block})"
fi fi
# get mem pool transactions # get mem pool transactions
mempool="$(bitcoin-cli -datadir=${bitcoin_dir} getmempoolinfo | jq -r '.size')" mempool="$(${network}-cli -datadir=${bitcoin_dir} getmempoolinfo | jq -r '.size')"
else else
btc_line2="${color_red}NOT RUNNING\t\t" btc_line2="${color_red}NOT RUNNING\t\t"
@ -105,7 +108,7 @@ fi
# get IP address & port # get IP address & port
local_ip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') local_ip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
public_ip=$(curl -s http://v4v6.ipv6-test.com/api/myip.php) public_ip=$(curl -s http://v4v6.ipv6-test.com/api/myip.php)
public_port=$(cat ${bitcoin_dir}/bitcoin.conf 2>/dev/null | grep port= | awk -F"=" '{print $2}') public_port=$(cat ${bitcoin_dir}/${network}.conf 2>/dev/null | grep port= | awk -F"=" '{print $2}')
if [ "${public_port}" = "" ]; then if [ "${public_port}" = "" ]; then
if [ $chain = "test" ]; then if [ $chain = "test" ]; then
public_port=18333 public_port=18333
@ -148,13 +151,14 @@ else
external_color="${color_red}" external_color="${color_red}"
fi fi
networkVersion = $(${network}-cli -cli -version | cut -d " " -f6)
printf " printf "
${color_yellow} ${color_yellow}
${color_yellow} ${color_yellow}
${color_yellow} ${color_yellow}
${color_yellow} ${color_yellow}%s ${color_green} ${ln_alias} ${color_yellow} ${color_yellow}%s ${color_green} ${ln_alias}
${color_yellow} ${color_gray}Bitcoin Fullnode + Lightning Network ${color_yellow} ${color_gray}$Fullnode + Lightning Network
${color_yellow} ${color_yellow}%s ${color_yellow} ${color_yellow}%s
${color_yellow} ,/ ${color_yellow} ${color_yellow} ,/ ${color_yellow}
${color_yellow} ,'/ ${color_gray}%s, CPU %s°C ${color_yellow} ,'/ ${color_gray}%s, CPU %s°C
@ -163,13 +167,13 @@ ${color_yellow} ,' /_____, ${color_gray}
${color_yellow} .'____ ,' ${color_gray}Local ${color_green}${local_ip}${color_gray}${network_rx}${network_tx} ${color_yellow} .'____ ,' ${color_gray}Local ${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public} ${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public}
${color_yellow} / ,' ${color_gray} ${color_yellow} / ,' ${color_gray}
${color_yellow} /,' ${color_gray}Bitcoin ${color_green}v0.16.1 ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s) ${color_yellow} /,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s)
${color_yellow} /' ${color_gray}LND ${color_green}v0.4.2 ${color_gray}wallet ${ln_walletbalance} sat ${color_yellow} /' ${color_gray}LND ${color_green}v0.4.2 ${color_gray}wallet ${ln_walletbalance} sat
${color_yellow} ${color_gray}${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat ${color_yellow} ${color_gray}${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat
${color_yellow} ${ln_external} ${color_yellow} ${ln_external}
${color_yellow} ${color_yellow}
" \ " \
"RaspiBlitz v0.3" \ "RaspiBlitz v0.4" \
"-------------------------------------------" \ "-------------------------------------------" \
"${load##up*, }" "${temp}" \ "${load##up*, }" "${temp}" \
"${hdd}" "${sync_percentage}" "${hdd}" "${sync_percentage}"

35
home.admin/00mainMenu.sh

@ -9,6 +9,12 @@ TITLE=""
MENU="Choose one of the following options:" MENU="Choose one of the following options:"
OPTIONS=() OPTIONS=()
# default config values (my get changed later)
if [ ! -f ./.network ]; then
echo "bitcoin" > /home/admin/.network
fi
network=`cat .network`
## get actual setup state ## get actual setup state
setupState=0; setupState=0;
if [ -f "/home/admin/.setup" ]; then if [ -f "/home/admin/.setup" ]; then
@ -19,17 +25,18 @@ if [ ${setupState} -eq 0 ]; then
# start setup # start setup
BACKTITLE="RaspiBlitz - Setup" BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡" TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nYou need to setup and init Bitcoin and Lightning services: \n " MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(1 "Start the Setup of your RaspiBlitz") OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
HEIGHT=10 LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" )
HEIGHT=11
elif [ ${setupState} -lt 100 ]; then elif [ ${setupState} -lt 100 ]; then
# continue setup # continue setup
BACKTITLE="RaspiBlitz - Setup" BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡" TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nContinue setup and init of Bitcoin and Lightning services: \n " MENU="\nThe setup process in snot finished yet: \n "
OPTIONS+=(1 "Continue Setup of your RaspiBlitz") OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10 HEIGHT=10
else else
@ -38,13 +45,13 @@ else
uptimesecs=$(awk '{print $1}' /proc/uptime | awk '{print int($1)}') uptimesecs=$(awk '{print $1}' /proc/uptime | awk '{print int($1)}')
waittimesecs=$(expr 150 - $uptimesecs) waittimesecs=$(expr 150 - $uptimesecs)
if [ ${waittimesecs} -gt 0 ]; then if [ ${waittimesecs} -gt 0 ]; then
dialog --pause " Waiting for Bitcoin to startup and init ..." 8 58 ${waittimesecs} dialog --pause " Waiting for ${network} to startup and init ..." 8 58 ${waittimesecs}
fi fi
# MAIN MENU AFTER SETUP # MAIN MENU AFTER SETUP
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain') chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock) locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then if [ ${locked} -gt 0 ]; then
# LOCK SCREEN # LOCK SCREEN
@ -75,7 +82,17 @@ case $CHOICE in
CLOSE) CLOSE)
exit 1; exit 1;
;; ;;
1) # SETUP BITCOIN)
echo "bitcoin" > /home/admin/.network
./10setupBlitz.sh
exit 1;
;;
LITECOIN)
echo "litecoin" > /home/admin/.network
./10setupBlitz.sh
exit 1;
;;
CONTINUE)
./10setupBlitz.sh ./10setupBlitz.sh
exit 1; exit 1;
;; ;;

55
home.admin/10setupBlitz.sh

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
echo "" echo ""
# load network
network=`cat .network`
# CHECK WHAT IS ALREADY WORKING # CHECK WHAT IS ALREADY WORKING
# check list from top down - so ./10setupBlitz.sh # check list from top down - so ./10setupBlitz.sh
# and re-enters the setup process at the correct spot # and re-enters the setup process at the correct spot
@ -10,8 +13,8 @@ echo ""
lndRunning=$(systemctl status lnd.service | grep -c running) lndRunning=$(systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 1 ]; then if [ ${lndRunning} -eq 1 ]; then
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain') chain=$(${network}-cli -datadir=/home/${network}/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock) locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c false) lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c false)
if [ ${locked} -gt 0 ]; then if [ ${locked} -gt 0 ]; then
# LND wallet is locked # LND wallet is locked
@ -26,20 +29,20 @@ if [ ${lndRunning} -eq 1 ]; then
fi fi
# check if bitcoin is running # check if bitcoin is running
bitcoinRunning=$(systemctl status bitcoind.service | grep -c running) bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep -c blocks)
if [ ${bitcoinRunning} -eq 1 ]; then if [ ${bitcoinRunning} -eq 1 ]; then
echo "OK - Bitcoind is running" echo "OK - ${network}d is running"
echo "Next step run Lightning" echo "Next step run Lightning"
./70initLND.sh ./70initLND.sh
exit 1 exit 1
fi fi
# check if HDD is mounted # check if HDD is mounted
mountOK=$(df | grep -c /mnt/hdd) mountOK=$( df | grep -c /mnt/hdd )
if [ ${mountOK} -eq 1 ]; then if [ ${mountOK} -eq 1 ]; then
# if there are signs of blockchain data # are there any signs of blockchain data
if [ -d "/mnt/hdd/bitcoin" ]; then if [ -d "/mnt/hdd/${network}" ]; then
echo "UNKOWN STATE" echo "UNKOWN STATE"
echo "It seems that something went wrong during sync/download/copy of the blockchain." echo "It seems that something went wrong during sync/download/copy of the blockchain."
echo "Maybe try --> ./60finishHDD.sh" echo "Maybe try --> ./60finishHDD.sh"
@ -47,17 +50,32 @@ if [ ${mountOK} -eq 1 ]; then
fi fi
# HDD is empty - ask how to get Blockchain # HDD is empty - ask how to get Blockchain
_temp="./download/dialog.$$"
dialog --clear --beep --backtitle "RaspiBlitz" --title "Getting the Blockchain" \ #Bitcoin
--menu "You need a copy of the Blockchan - you have 3 options:" 13 75 4 \ if [ ${network} = "bitcoin" ]; then
1 "DOWNLOAD --> TESTNET + MAINNET thru torrent (RECOMMENDED 8h)" \ echo "Bitcoin Options"
2 "COPY --> TESTNET + MAINNET from another HDD (TRICKY 3h)" \ menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title "Getting the Blockchain" \
3 "SYNC --> JUST TESTNET thru Bitoin Network (FALLBACK)" 2>$_temp --menu "You need a copy of the Bitcoin Blockchain - you have 3 options:" 13 75 4 \
opt=${?} 1 "DOWNLOAD --> TESTNET + MAINNET thru torrent (RECOMMENDED 8h)" \
2 "COPY --> TESTNET + MAINNET from another HDD (TRICKY 3h)" \
3 "SYNC --> JUST TESTNET thru Bitoin Network (FALLBACK)" 2>&1 >/dev/tty)
# Litecoin
elif [ ${network} = "litecoin" ]; then
echo "Litecoin Options"
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title "Getting the Blockchain" \
--menu "You need a copy of the Litecoin Blockchain - you have 3 options:" 13 75 4 \
1 "DOWNLOAD --> MAINNET thru torrent (RECOMMENDED)" \
2 "COPY --> MAINNET from another HDD (TRICKY)" \
3 "SYNC --> MAINNET thru Litecoin Network (FALLBACK)" 2>&1 >/dev/tty)
# error
else
echo "FAIL Unkown network(${network})"
exit 1
fi
clear clear
if [ $opt != 0 ]; then rm $_temp; exit; fi
menuitem=`cat $_temp`
rm $_temp
case $menuitem in case $menuitem in
3) 3)
./50syncHDD.sh ./50syncHDD.sh
@ -73,6 +91,7 @@ if [ ${mountOK} -eq 1 ]; then
fi fi
# the HDD is not mounted --> very early stage of setup # the HDD is not mounted --> very early stage of setup
# if the script is called for the first time # if the script is called for the first time

15
home.admin/20initDialog.sh

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
_temp="./download/dialog.$$" _temp="./download/dialog.$$"
# load network
network=`cat .network`
# welcome and ask for name of RaspiBlitz # welcome and ask for name of RaspiBlitz
result="" result=""
while [ ${#result} -eq 0 ] while [ ${#result} -eq 0 ]
@ -14,6 +17,7 @@ while [ ${#result} -eq 0 ]
# set lightning alias # set lightning alias
sed -i "7s/.*/alias=$result/" ./assests/lnd.conf sed -i "7s/.*/alias=$result/" ./assests/lnd.conf
sed -i "7s/.*/alias=$result/" ./assests/lnd.litecoin.conf
# store hostname for later - to be set right before the next reboot # store hostname for later - to be set right before the next reboot
# work around - because without a reboot the hostname seems not updates in the whole system # work around - because without a reboot the hostname seems not updates in the whole system
@ -24,7 +28,7 @@ dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different pa
Referenced as password A, B, C and D. Referenced as password A, B, C and D.
A) Master User Password A) Master User Password
B) Bitcoin RPC Password B) Blockchain RPC Password
C) LND Wallet Password C) LND Wallet Password
D) LND Seed Password D) LND Seed Password
@ -68,10 +72,11 @@ while [ ${#result} -lt 8 ]
shred $_temp shred $_temp
done done
# set Bitcoin RPC Password (for admin bitcoin-cli & template for user bitcoin bitcoind) # set Blockchain RPC Password (for admin cli & template for user bitcoin)
sed -i "14s/.*/rpcpassword=$result/" ./assets/bitcoin.conf sed -i "14s/.*/rpcpassword=$result/" ./assets/${network}.conf
sed -i "6s/.*/rpcpassword=$result/" ./.bitcoin/bitcoin.conf sed -i "6s/.*/rpcpassword=$result/" ./.${network}/${network}.conf
# success info dialog # success info dialog
dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52 dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52
clear clear

2
home.admin/40addHDD.sh

@ -44,7 +44,7 @@ if [ ${existsHDD} -eq 1 ]; then
echo "40" > /home/admin/.setup echo "40" > /home/admin/.setup
echo "*** Analysing HDD Content ***" echo "*** Analysing HDD Content ***"
if [ -d "/mnt/hdd/bitcoin" ]; then if [ -d "/mnt/hdd/${network}" ]; then
echo "Looks like the HDD is prepared with the Blockchain." echo "Looks like the HDD is prepared with the Blockchain."
echo "Continuing with finishing the system setup ..." echo "Continuing with finishing the system setup ..."
./60finishHDD.sh ./60finishHDD.sh

30
home.admin/50copyHDD.sh

@ -1,4 +1,8 @@
#!/bin/sh #!/bin/sh
# load network
network=`cat .network`
echo "" echo ""
echo "*** Check 1st HDD ***" echo "*** Check 1st HDD ***"
sleep 4 sleep 4
@ -19,7 +23,7 @@ echo "Like this one: https://www.amazon.de/dp/B00ZJBIHVY"
echo "If you see on LCD a error on connecting the 2nd HDD do a restart." echo "If you see on LCD a error on connecting the 2nd HDD do a restart."
echo "" echo ""
echo "You can use the HDD of another RaspiBlitz for this." echo "You can use the HDD of another RaspiBlitz for this."
echo "The 2nd HDD needs to be formated Ext4/exFAT and the folder 'bitcoin' is in root of HDD." echo "The 2nd HDD needs to be formated Ext4/exFAT and the folder '${network}' is in root of HDD."
echo "" echo ""
echo "**********************************" echo "**********************************"
echo "--> Please connect now the 2nd HDD" echo "--> Please connect now the 2nd HDD"
@ -72,18 +76,18 @@ echo ""
echo "*** Copy Blockchain ***" echo "*** Copy Blockchain ***"
sudo rsync --append --info=progress2 -a /mnt/genesis/bitcoin /mnt/hdd/ sudo rsync --append --info=progress2 -a /mnt/genesis/bitcoin /mnt/hdd/
echo "cleaning up - ok if files do not exists" echo "cleaning up - ok if files do not exists"
sudo rm /mnt/hdd/bitcoin/bitcoin.conf sudo rm /mnt/hdd/${network}/${network}.conf
sudo rm /mnt/hdd/bitcoin/bitcoin.pid sudo rm /mnt/hdd/${network}/${network}.pid
sudo rm /mnt/hdd/bitcoin/banlist.dat sudo rm /mnt/hdd/${network}/banlist.dat
sudo rm /mnt/hdd/bitcoin/debug.log sudo rm /mnt/hdd/${network}/debug.log
sudo rm /mnt/hdd/bitcoin/fee_estimates.dat sudo rm /mnt/hdd/${network}/fee_estimates.dat
sudo rm /mnt/hdd/bitcoin/mempool.dat sudo rm /mnt/hdd/${network}/mempool.dat
sudo rm /mnt/hdd/bitcoin/peers.dat sudo rm /mnt/hdd/${network}/peers.dat
sudo rm /mnt/hdd/bitcoin/testnet3/banlist.dat sudo rm /mnt/hdd/${network}/testnet3/banlist.dat
sudo rm /mnt/hdd/bitcoin/testnet3/debug.log sudo rm /mnt/hdd/${network}/testnet3/debug.log
sudo rm /mnt/hdd/bitcoin/testnet3/fee_estimates.dat sudo rm /mnt/hdd/${network}/testnet3/fee_estimates.dat
sudo rm /mnt/hdd/bitcoin/testnet3/mempool.dat sudo rm /mnt/hdd/${network}/testnet3/mempool.dat
sudo rm /mnt/hdd/bitcoin/testnet3/peers.dat sudo rm /mnt/hdd/${network}/testnet3/peers.dat
sudo umount -l /mnt/genesis sudo umount -l /mnt/genesis
echo "OK - Copy done :)" echo "OK - Copy done :)"
echo "" echo ""

27
home.admin/50downloadHDD.sh

@ -1,16 +1,30 @@
#!/bin/sh #!/bin/sh
# name of torrentfile = name of directory in torrent # *** BITCOIN Torrent ***
torrent="raspiblitz-hdd-2018-07-16" bitcoinTorrent="raspiblitz-hdd-2018-07-16"
# size of a valid download (run on seed directory 'du -s ./[TORRENTDIRECTORY]') bitcoinTorrentsize=231230512
torrentsize=231230512
# *** LITECOIN Torrent ***
litecoinTorrent="raspiblitz-litecoin-2018-07-28"
litecoinTorrentsize=100
# load network
network=`cat .network`
# set torrent based on network
torrent=$bitcoinTorrent
torrentsize=$bitcoinTorrentsize
if [ "$network" = "litecoin" ]; then
torrent=$litecoinTorrent
torrentsize=$litecoinTorrentsize
fi
echo "" echo ""
echo "*** Checking HDD ***" echo "*** Checking HDD ***"
mountOK=$(df | grep -c /mnt/hdd) mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then if [ ${mountOK} -eq 1 ]; then
# HDD is mounted # HDD is mounted
if [ -d "/mnt/hdd/bitcoin" ]; then if [ -d "/mnt/hdd/${network}" ]; then
# HDD has already content # HDD has already content
echo "It seems that HDD has already content. Try to continue with ./finishHDD.sh" echo "It seems that HDD has already content. Try to continue with ./finishHDD.sh"
else else
@ -23,6 +37,7 @@ if [ ${mountOK} -eq 1 ]; then
while [ $downloading -eq 1 ] while [ $downloading -eq 1 ]
do do
echo "*** Downloading HDD ***" echo "*** Downloading HDD ***"
echo "torrentFile: ${torrent}"
tmpfile=$(mktemp) tmpfile=$(mktemp)
chmod a+x $tmpfile chmod a+x $tmpfile
echo "killall transmission-cli" > $tmpfile echo "killall transmission-cli" > $tmpfile
@ -70,7 +85,7 @@ if [ ${mountOK} -eq 1 ]; then
echo "*** Moving Files ***" echo "*** Moving Files ***"
echo "moving files ..." echo "moving files ..."
sudo mv /mnt/hdd/$torrent /mnt/hdd/bitcoin sudo mv /mnt/hdd/$torrent /mnt/hdd/${network}
echo "" echo ""
# set SetupState # set SetupState

40
home.admin/50syncHDD.sh

@ -1,25 +1,31 @@
#!/bin/sh #!/bin/sh
msg="" # load network
msg="$msg Syncing is just practical for Bitcoin TESTNET!\n" network=`cat .network`
msg="$msg TESTNET is OK for learning, testing and development.\n"
msg="$msg MAINNET is where things get real and fun.\n"
msg="$msg \n"
msg="$msg Syncing MAINNET on a raspberry is NOT practical.\n"
msg="$msg If you want MAINET, go back & try DOWNLOAD.\n"
msg="$msg \n"
msg="$msg Do you really want to work with ONLY TESTNET?"
dialog --title " WARNING " --yesno "${msg}" 12 57 # only show warning when bitcoin
response=$? if [ "$network" = "bitcoin" ]; then
case $response in msg=""
0) echo "--> OK";; msg="$msg Syncing is just practical for Bitcoin TESTNET!\n"
1) ./10setupBlitz.sh; exit 1;; msg="$msg TESTNET is OK for learning, testing and development.\n"
255) ./10setupBlitz.sh; exit 1;; msg="$msg MAINNET is where things get real and fun.\n"
esac msg="$msg \n"
msg="$msg Syncing MAINNET on a raspberry is NOT practical.\n"
msg="$msg If you want MAINET, go back & try DOWNLOAD.\n"
msg="$msg \n"
msg="$msg Do you really want to work with ONLY TESTNET?"
dialog --title " WARNING " --yesno "${msg}" 12 57
response=$?
case $response in
0) echo "--> OK";;
1) ./10setupBlitz.sh; exit 1;;
255) ./10setupBlitz.sh; exit 1;;
esac
fi
echo "*** Activating Blockain Sync ***" echo "*** Activating Blockain Sync ***"
sudo mkdir /mnt/hdd/bitcoin sudo mkdir /mnt/hdd/${network}
echo "OK - sync is activated" echo "OK - sync is activated"
# set SetupState # set SetupState

33
home.admin/60finishHDD.sh

@ -1,34 +1,39 @@
#!/bin/sh #!/bin/sh
echo "" echo ""
# load network
network=`cat .network`
echo "*** Checking HDD ***" echo "*** Checking HDD ***"
mountOK=$(df | grep -c /mnt/hdd) mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then if [ ${mountOK} -eq 1 ]; then
# HDD is mounted # HDD is mounted
if [ -d "/mnt/hdd/bitcoin" ]; then if [ -d "/mnt/hdd/${network}" ]; then
# HDD has content - continue # HDD has content - continue
echo "OK - HDD is ready." echo "OK - HDD is ready."
###### LINK HDD ###### LINK HDD
echo "" echo ""
echo "*** Prepare Bitcoin ***" echo "*** Prepare ${network} ***"
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
sudo ln -s /mnt/hdd/bitcoin /home/bitcoin/.bitcoin sudo ln -s /mnt/hdd/${network} /home/bitcoin/.${network}
sudo mkdir /mnt/hdd/lnd sudo mkdir /mnt/hdd/lnd
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin sudo chown -R bitcoin:bitcoin /mnt/hdd/${network}
sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd
sudo chown -R bitcoin:bitcoin /home/bitcoin/.bitcoin sudo chown -R bitcoin:bitcoin /home/bitcoin/.${network}
sudo chown -R bitcoin:bitcoin /home/bitcoin/.lnd sudo chown -R bitcoin:bitcoin /home/bitcoin/.lnd
echo "OK - Bitcoin setup ready" echo "OK - ${network} setup ready"
###### START BITCOIN SERVICE ###### START NETWORK SERVICE
echo "" echo ""
echo "*** Start Bitcoin ***" echo "*** Start ${network} ***"
sudo systemctl enable bitcoind.service echo "This can take a while .."
sudo systemctl start bitcoind.service sudo systemctl enable ${network}d.service
echo "Giving bitcoind service 180 seconds to init - please wait ..." sudo systemctl start ${network}d.service
echo "Giving ${network}d service 180 seconds to init - please wait ..."
sleep 180 sleep 180
echo "OK - bitcoind started" echo "OK - ${network}d started"
sleep 2 sleep 2
# set SetupState # set SetupState
@ -43,4 +48,4 @@ if [ ${mountOK} -eq 1 ]; then
else else
# HDD is not available yet # HDD is not available yet
echo "FAIL - HDD is not mounted." echo "FAIL - HDD is not mounted."
fi fi

52
home.admin/70initLND.sh

@ -1,16 +1,19 @@
#!/bin/sh #!/bin/sh
echo "" echo ""
# load network
network=`cat .network`
# verify that bitcoin is running # verify that bitcoin is running
echo "*** Checking Bitcoin ***" echo "*** Checking ${network} ***"
bitcoinRunning=$(systemctl status bitcoind.service | grep -c running) bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep -c blocks)
if [ ${bitcoinRunning} -eq 0 ]; then if [ ${bitcoinRunning} -eq 0 ]; then
# HDD is not available yet # HDD is not available yet
echo "FAIL - Bitcoind is not running" echo "FAIL - ${network}d is not running"
echo "recheck with orignal tutorial -->" echo "recheck with orignal tutorial -->"
echo "https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md" echo "https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md"
fi fi
echo "OK - Bitcoind is running" echo "OK - ${network}d is running"
echo "" echo ""
###### Wait for Blochain Sync ###### Wait for Blochain Sync
@ -18,20 +21,25 @@ echo "*** Syncing Blockchain ***"
ready=0 ready=0
while [ ${ready} -eq 0 ] while [ ${ready} -eq 0 ]
do do
progress="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.verificationprogress')" progress="$(sudo -u bitcoin ${network}-cli getblockchaininfo | jq -r '.verificationprogress')"
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')") verySmallProgress=$(echo $progress | grep -c 'e-');
if [ ${verySmallProgress} -eq 1 ]; then
progress="0.00";
fi
ready=$(echo $progress'>0.99' | bc -l) ready=$(echo $progress'>0.99' | bc -l)
if [ ${ready} -eq 0 ]; then sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
#echo "progress($progress) verySmallProgress($verySmallProgress) ready($ready) sync_percentage($sync_percentage)"
if [ ${#ready} -eq 0 ]; then
echo "waiting for init ... can take a while"
ready=0
elif [ "$sync_percentage" = "0.00%" ]; then
echo "waiting for network ... can take a while"
ready=0
elif [ ${ready} -eq 0 ]; then
echo "${sync_percentage}" echo "${sync_percentage}"
else else
if [ ${ready} -eq 1 ]; then echo "finishing sync ... can take a while"
echo "${sync_percentage}"
else
echo "waiting to start sync"
ready=0
fi
fi fi
echo "${sync_percentage}"
sleep 3 sleep 3
done done
echo "OK - Blockchain is synced" echo "OK - Blockchain is synced"
@ -41,7 +49,13 @@ echo ""
echo "*** LND Config ***" echo "*** LND Config ***"
configExists=$( sudo ls /mnt/hdd/lnd/ | grep -c lnd.conf ) configExists=$( sudo ls /mnt/hdd/lnd/ | grep -c lnd.conf )
if [ ${configExists} -eq 0 ]; then if [ ${configExists} -eq 0 ]; then
sudo cp /home/admin/assets/lnd.conf /mnt/hdd/lnd/lnd.conf if [ "$network" = "litecoin" ]; then
# litecoin
sudo cp /home/admin/assets/lnd.litecoin.conf /mnt/hdd/lnd/lnd.conf
else
# bitcoin
sudo cp /home/admin/assets/lnd.conf /mnt/hdd/lnd/lnd.conf
fi
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
if [ -d /home/bitcoin/.lnd ]; then if [ -d /home/bitcoin/.lnd ]; then
echo "OK - LND config written" echo "OK - LND config written"
@ -82,7 +96,7 @@ setupStep=$(sudo cat "/home/admin/.setup")
if [ ${setupStep} -lt 65 ]; then if [ ${setupStep} -lt 65 ]; then
# setup state signals, that no wallet has been created yet # setup state signals, that no wallet has been created yet
dialog --backtitle "RaspiBlitz - LND Lightning Wallet" --msgbox " dialog --backtitle "RaspiBlitz - LND Lightning Wallet" --msgbox "
Bitcoin and Lighthing Services are installed. ${network} and Lighthing Services are installed.
You now need to setup your Lightning Wallet: You now need to setup your Lightning Wallet:
We will now call the command: lncli create We will now call the command: lncli create
@ -139,8 +153,8 @@ fi
###### Unlock Wallet (if needed) ###### Unlock Wallet (if needed)
echo "*** Check Wallet Lock ***" echo "*** Check Wallet Lock ***"
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain') chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock) locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then if [ ${locked} -gt 0 ]; then
echo "OK - Wallet is locked ... starting unlocking dialog" echo "OK - Wallet is locked ... starting unlocking dialog"
./unlockLND.sh ./unlockLND.sh
@ -152,7 +166,7 @@ fi
echo "" echo ""
echo "*** Check LND Sync ***" echo "*** Check LND Sync ***"
item=0 item=0
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')" chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c true) lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 0 ]; then if [ ${lndSyncing} -eq 0 ]; then
echo "OK - wait for LND to be synced" echo "OK - wait for LND to be synced"

11
home.admin/80scanLND.sh

@ -1,13 +1,16 @@
# load network
network=`sudo cat /home/admin/.network`
# parse the actual scanned height progress from LND logs # parse the actual scanned height progress from LND logs
item=0 item=0
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')" chain="$(sudo -u bitcoin ${network}-cli getblockchaininfo | jq -r '.chain')"
gotData=$(sudo tail -n 100 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c height) gotData=$(sudo tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c height)
if [ ${gotData} -gt 0 ]; then if [ ${gotData} -gt 0 ]; then
item=$(sudo tail -n 100 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep height | tail -n1 | awk '{print $9} {print $10} {print $11} {print $12}' | tr -dc '0-9') item=$(sudo tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep height | tail -n1 | awk '{print $9} {print $10} {print $11} {print $12}' | tr -dc '0-9')
fi fi
# get total number of blocks # get total number of blocks
total=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.blocks') total=$(sudo -u bitcoin ${network}-cli getblockchaininfo | jq -r '.blocks')
# calculate progress in percent # calculate progress in percent
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }") percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }")

8
home.admin/AAunlockLND.sh

@ -1,16 +1,20 @@
#!/bin/sh #!/bin/sh
# load network
network=`.network`
echo "" echo ""
echo "****************************************************************************" echo "****************************************************************************"
echo "Unlock LND Wallet --> lncli unlock" echo "Unlock LND Wallet --> lncli unlock"
echo "****************************************************************************" echo "****************************************************************************"
echo "HELP: Enter your PASSWORD C" echo "HELP: Enter your PASSWORD C"
echo "****************************************************************************" echo "****************************************************************************"
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')" chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
while : while :
do do
lncli unlock lncli unlock
sleep 4 sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock) locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -eq 0 ]; then if [ ${locked} -eq 0 ]; then
break break
fi fi

25
home.admin/XXcleanHDD.sh

@ -1,22 +1,25 @@
echo "" echo ""
# load network
network=`cat .network`
echo "!!!! This will DELETE your personal data from the HDD !!!!" echo "!!!! This will DELETE your personal data from the HDD !!!!"
echo "--> use the HDD with just blockchain in a fresh setup" echo "--> use the HDD with just blockchain in a fresh setup"
echo "Press ENTER to continue - CTRL+c to CANCEL" echo "Press ENTER to continue - CTRL+c to CANCEL"
read key read key
sudo dphys-swapfile swapoff sudo dphys-swapfile swapoff
sudo systemctl stop bitcoind.service sudo systemctl stop ${network}d.service
sudo systemctl stop lnd.service sudo systemctl stop lnd.service
sudo rm -f -r /mnt/hdd/lnd sudo rm -f -r /mnt/hdd/lnd
sudo rm -f /mnt/hdd/swapfile sudo rm -f /mnt/hdd/swapfile
sudo rm -f /mnt/hdd/bitcoin/bitcoin.conf sudo rm -f /mnt/hdd/${network}/${network}.conf
sudo rm -f /mnt/hdd/bitcoin/bitcoin.pid sudo rm -f /mnt/hdd/${network}/${network}.pid
sudo rm -f /mnt/hdd/bitcoin/*.dat sudo rm -f /mnt/hdd/${network}/*.dat
sudo rm -f /mnt/hdd/bitcoin/*.log sudo rm -f /mnt/hdd/${network}/*.log
sudo rm -f /mnt/hdd/bitcoin/bitcoin.conf sudo rm -f /mnt/hdd/${network}/testnet3/*.dat
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.dat sudo rm -f /mnt/hdd/${network}/testnet3/*.log
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.log sudo rm -f /mnt/hdd/${network}/testnet3/.lock
sudo rm -f /mnt/hdd/bitcoin/testnet3/.lock sudo rm -f -r /mnt/hdd/${network}/database
sudo rm -f -r /mnt/hdd/bitcoin/database sudo chown admin:admin -R /mnt/hdd/${network}
sudo chown admin:admin -R /mnt/hdd/bitcoin
echo "1" > /home/admin/.setup echo "1" > /home/admin/.setup
echo "OK - the HDD is now clean" echo "OK - the HDD is now clean"

28
home.admin/assets/litecoin.conf

@ -0,0 +1,28 @@
# litecoind configuration
# lightning on litecoin just has mainnet
#testnet=1
# Bitcoind options
server=1
daemon=1
txindex=1
disablewallet=1
# Connection settings
rpcuser=raspibolt
# LINE15 -insert-> rpcpassword=[PASSWORDB]
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28332
# Raspberry Pi optimizations
dbcache=100
maxorphantx=10
maxmempool=50
maxconnections=40
maxuploadtarget=5000
# litecoin specials
discardfee=0.00000001
mintxfee=0.00000001
minrelaytxfee=0.00000001

21
home.admin/assets/lnd.litecoin.conf

@ -0,0 +1,21 @@
# lnd configuration
[Application Options]
debuglevel=info
debughtlc=true
maxpendingchannels=5
# LINE7 -insert-> alias=[ALIAS]
color=#68F442
[Litecoin]
litecoin.active=1
litecoin.mainnet=1
litecoin.node=litecoind
litecoind.rpcuser=jason
litecoind.rpcpass=litecoin
litecoind.zmqpath=tcp://127.0.0.1:28332
[autopilot]
autopilot.active=1
autopilot.maxchannels=5
autopilot.allocation=0.6
Loading…
Cancel
Save