From 741795bcf1d41e9b74707904036036055a9433d6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 20:17:51 +0100 Subject: [PATCH 001/162] try cpulimit on rtorrent --- build_sdcard.sh | 1 + home.admin/50torrentHDD.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build_sdcard.sh b/build_sdcard.sh index 37d445c..b750018 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -569,6 +569,7 @@ sudo apt-get -y install exfat-fuse # for blockchain torrent download sudo apt-get -y install transmission-cli sudo apt-get -y install rtorrent +sudo apt-get -y install cpulimit # for background downloading sudo apt-get -y install screen diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 0a92175..1f0ae61 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -114,7 +114,7 @@ if [ ${torrentComplete1} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: blockchain" - command1="sudo nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" + command1="sudo cpulimit -l 20 nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" screenCommand="screen -S blockchain -L screen.log -dm ${command1}" echo "${screenCommand}" bash -c "${screenCommand}" @@ -138,7 +138,7 @@ if [ ${torrentComplete2} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: update" - command2="sudo nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" + command2="sudo cpulimit -l 20 nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" screenCommand="screen -S update -L screen.log -dm ${command2}" echo "${screenCommand}" bash -c "${screenCommand}" From a8906c3297a3a6392734eb4df5f589812354b477 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 20:18:21 +0100 Subject: [PATCH 002/162] put torrent with cpulimit in background --- home.admin/50torrentHDD.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 1f0ae61..5820b85 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -98,6 +98,16 @@ if [ "${setupStep}" = "100" ] && [ ${#1} -eq 0 ]; then sudo systemctl stop ${network}d fi +############################## +# Force Torrent Backgground +############################## + +processTweaks="" +if [ "$1" == "backup-torrent-hosting" ]; then + echo "Forcing running rTorrent in background ..." + processTweaks="cpulimit -l 20 nice -n 10 chrt -r 1 " +fi + ############################## # CHECK TORRENT 1 "BLOCKCHAIN" ############################## @@ -114,7 +124,7 @@ if [ ${torrentComplete1} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: blockchain" - command1="sudo cpulimit -l 20 nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" + command1="sudo ${processTweaks}rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" screenCommand="screen -S blockchain -L screen.log -dm ${command1}" echo "${screenCommand}" bash -c "${screenCommand}" @@ -138,7 +148,7 @@ if [ ${torrentComplete2} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: update" - command2="sudo cpulimit -l 20 nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" + command2="sudo ${processTweaks}rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" screenCommand="screen -S update -L screen.log -dm ${command2}" echo "${screenCommand}" bash -c "${screenCommand}" From 7ce1a9550f6b15b248dd893c6e84f44ed5eb8b61 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 21:35:52 +0100 Subject: [PATCH 003/162] set limits after processes --- home.admin/50torrentHDD.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 5820b85..7f499d8 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -98,16 +98,6 @@ if [ "${setupStep}" = "100" ] && [ ${#1} -eq 0 ]; then sudo systemctl stop ${network}d fi -############################## -# Force Torrent Backgground -############################## - -processTweaks="" -if [ "$1" == "backup-torrent-hosting" ]; then - echo "Forcing running rTorrent in background ..." - processTweaks="cpulimit -l 20 nice -n 10 chrt -r 1 " -fi - ############################## # CHECK TORRENT 1 "BLOCKCHAIN" ############################## @@ -124,7 +114,7 @@ if [ ${torrentComplete1} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: blockchain" - command1="sudo ${processTweaks}rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" + command1="sudo nice -n 10 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" screenCommand="screen -S blockchain -L screen.log -dm ${command1}" echo "${screenCommand}" bash -c "${screenCommand}" @@ -148,7 +138,7 @@ if [ ${torrentComplete2} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: update" - command2="sudo ${processTweaks}rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" + command2="sudo nice -n 10 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" screenCommand="screen -S update -L screen.log -dm ${command2}" echo "${screenCommand}" bash -c "${screenCommand}" @@ -163,6 +153,8 @@ sleep 2 # just let torrent start and run in the background if [ "$1" == "backup-torrent-hosting" ]; then + + # changing config - so it can be startup again after a reboot by bootstrap source /mnt/hdd/raspiblitz.conf if [ ${#backupTorrentSeeding} -eq 0 ]; then @@ -170,6 +162,16 @@ if [ "$1" == "backup-torrent-hosting" ]; then else sudo sed -i "s/^backupTorrentSeeding=.*/backupTorrentSeeding=on/g" /mnt/hdd/raspiblitz.conf fi + + # set the torrents processes to cpulimit 20% + sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) + echo "Putting rTorrent blochchain 'BASE' (PID=${sessionPID}) to background ..." + sudo cpulimit -p ${sessionPID} -l 50 + chrt -f -p 1 ${sessionPID} + sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) + echo "Putting rTorrent blochchain 'UPDATE' (PID=${sessionPID}) to background ..." + sudo cpulimit -p ${sessionPID} -l 50 + chrt -f -p 1 ${sessionPID} echo "Done BACKUP TORRENT HOSTING" exit fi From 73a8a319e3f5a5fd71bd0a5311efa85f8594f8f3 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 22:09:59 +0100 Subject: [PATCH 004/162] fix missing end of if --- home.admin/70initLND.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 6d8f31a..5a86702 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -206,6 +206,10 @@ if [ ${walletExists} -eq 0 ]; then fi +else + echo "OK - LND wallet already exists." +fi + dialog --pause " Waiting for LND - please wait .." 8 58 60 ###### Copy LND macaroons to admin @@ -259,5 +263,4 @@ sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info ###### finishSetup sudo ./90finishSetup.sh -sudo ./95finalSetup.sh - +sudo ./95finalSetup.sh \ No newline at end of file From d39a46dd5a976e4df93d47aa794201cc1c3c03c0 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 22:10:13 +0100 Subject: [PATCH 005/162] just run CPULIMIT afterwards --- home.admin/50torrentHDD.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 7f499d8..22e188c 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -114,7 +114,7 @@ if [ ${torrentComplete1} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: blockchain" - command1="sudo nice -n 10 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" + command1="sudo nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" screenCommand="screen -S blockchain -L screen.log -dm ${command1}" echo "${screenCommand}" bash -c "${screenCommand}" @@ -138,7 +138,7 @@ if [ ${torrentComplete2} -eq 0 ]; then # start torrent download in screen session echo "starting torrent: update" - command2="sudo nice -n 10 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" + command2="sudo nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" screenCommand="screen -S update -L screen.log -dm ${command2}" echo "${screenCommand}" bash -c "${screenCommand}" @@ -165,13 +165,11 @@ if [ "$1" == "backup-torrent-hosting" ]; then # set the torrents processes to cpulimit 20% sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) - echo "Putting rTorrent blochchain 'BASE' (PID=${sessionPID}) to background ..." - sudo cpulimit -p ${sessionPID} -l 50 - chrt -f -p 1 ${sessionPID} + echo "Putting rTorrent blockchain 'BASE' (PID=${sessionPID}) to background ... (please wait)" + sudo cpulimit -p ${sessionPID} -l 25 & sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) - echo "Putting rTorrent blochchain 'UPDATE' (PID=${sessionPID}) to background ..." - sudo cpulimit -p ${sessionPID} -l 50 - chrt -f -p 1 ${sessionPID} + echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)" + sudo cpulimit -p ${sessionPID} -l 25 & echo "Done BACKUP TORRENT HOSTING" exit fi From 20be83076acc61aa8d2fcfb162dfd6beed2acaf5 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 22:44:10 +0100 Subject: [PATCH 006/162] handle error case --- home.admin/50torrentHDD.sh | 2 +- home.admin/70initLND.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 22e188c..ffac194 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -154,7 +154,6 @@ sleep 2 if [ "$1" == "backup-torrent-hosting" ]; then - # changing config - so it can be startup again after a reboot by bootstrap source /mnt/hdd/raspiblitz.conf if [ ${#backupTorrentSeeding} -eq 0 ]; then @@ -170,6 +169,7 @@ if [ "$1" == "backup-torrent-hosting" ]; then sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)" sudo cpulimit -p ${sessionPID} -l 25 & + sleep 6 echo "Done BACKUP TORRENT HOSTING" exit fi diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 5a86702..1c561d2 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -143,7 +143,7 @@ if [ ${walletExists} -eq 0 ]; then # UI: Ask if user wants NEW wallet or RECOVER a wallet OPTIONS=(NEW "Setup a brand new Lightning Node (DEFAULT)" \ OLD "I had a old Node I want to recover/restore") - CHOICE=$(dialog --backtitle "RaspiBlitz - LND Setup" --clear --title "LND Data & Wallet" --menu "How to setup your node?:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) echo "choice($CHOICE)" if [ "${CHOICE}" == "NEW" ]; then @@ -167,10 +167,18 @@ if [ ${walletExists} -eq 0 ]; then sudo shred /home/admin/.pass.tmp 2>/dev/null # in case of error - retry - if [ ${#err} -eq 0 ]; then + if [ ${#err} -gt 0 ]; then whiptail --title "lnd.initwallet.py - ERROR" --msgbox "${err}" 8 50 /home/admin/70initLND.sh exit 1 + else + if [ ${#seedwords} -eq 0 ]; then + echo "FAIL!! -> MISSING seedwords data - but also no err data ?!?" + echo "CHECK output data above - PRESS ENTER to retart 70initLND.sh" + read key + /home/admin/70initLND.sh + exit 1 + fi fi # TODO: create numbered string in rows From 6a9b40f9f35efb8cc8b6507dc8d03c2246d5718a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 14 Apr 2019 23:02:36 +0100 Subject: [PATCH 007/162] every rtorrent process cpulimit --- home.admin/50torrentHDD.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index ffac194..f475050 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -162,14 +162,26 @@ if [ "$1" == "backup-torrent-hosting" ]; then sudo sed -i "s/^backupTorrentSeeding=.*/backupTorrentSeeding=on/g" /mnt/hdd/raspiblitz.conf fi - # set the torrents processes to cpulimit 20% - sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) - echo "Putting rTorrent blockchain 'BASE' (PID=${sessionPID}) to background ... (please wait)" - sudo cpulimit -p ${sessionPID} -l 25 & - sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) - echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)" - sudo cpulimit -p ${sessionPID} -l 25 & + # set the torrents processes to cpulimit 25% + sleep 6 + echo "" + rtorrentPIDs=$(ps axf | grep "rtorrent" | awk '{$1=$1;print}' | cut -d' ' -f1) + while read -r pid ; do + ps ${pid} | grep "rtorrent" + echo "---> reducing this rTorrent process to 25% CPU" + sudo cpulimit -p ${pid} -l 25 & + echo "" + done < <(echo "${rtorrentPIDs}") sleep 6 + + # set the torrents processes to cpulimit 20% + #sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) + #echo "Putting rTorrent blockchain 'BASE' (PID=${sessionPID}) to background ... (please wait)" + #sudo cpulimit -p ${sessionPID} -l 25 & + #sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) + #echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)" + #sudo cpulimit -p ${sessionPID} -l 25 & + echo "Done BACKUP TORRENT HOSTING" exit fi From 8242e0311879c4e2f3c526f125823b2e381378ae Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 00:12:32 +0100 Subject: [PATCH 008/162] fix virtualenv --- build_sdcard.sh | 5 +---- home.admin/70initLND.sh | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/build_sdcard.sh b/build_sdcard.sh index b750018..c0760b8 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -488,10 +488,7 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1 echo "to switch between python2/3: sudo update-alternatives --config python" sudo apt-get -f -y install virtualenv -sudo -u admin virtualenv lnd -sudo -u admin source lnd/bin/activate -sudo -u admin pip install grpcio grpcio-tools googleapis-common-protos - +sudo -u admin bash -c "cd; virtualenv python-env-lnd; source /home/admin/python-env-lnd/bin/activate; pip install grpcio grpcio-tools googleapis-common-protos" echo "" # Go is needed for ZAP connect later diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 1c561d2..b7c6b6e 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -161,8 +161,8 @@ if [ ${walletExists} -eq 0 ]; then fi # generate wallet with seed and set passwordC - source lnd/bin/activate - sudo python /home/admin/config.scripts/lnd.initwallet.py new ${passwordC} > /home/admin/.seed.tmp + source /home/admin/python-env-lnd/bin/activate + python /home/admin/config.scripts/lnd.initwallet.py new ${passwordC} > /home/admin/.seed.tmp source /home/admin/.seed.tmp sudo shred /home/admin/.pass.tmp 2>/dev/null @@ -174,7 +174,7 @@ if [ ${walletExists} -eq 0 ]; then else if [ ${#seedwords} -eq 0 ]; then echo "FAIL!! -> MISSING seedwords data - but also no err data ?!?" - echo "CHECK output data above - PRESS ENTER to retart 70initLND.sh" + echo "CHECK output data above - PRESS ENTER to restart 70initLND.sh" read key /home/admin/70initLND.sh exit 1 From 02bc1d3b3ca9fe9ed03e7058dd1a8d85ca1c9a18 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 01:15:29 +0100 Subject: [PATCH 009/162] added video info --- WORKSHOP.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WORKSHOP.md b/WORKSHOP.md index f7039b8..9efc376 100644 --- a/WORKSHOP.md +++ b/WORKSHOP.md @@ -108,6 +108,9 @@ Check how much time is left to go thru the next steps of connecting to peers, fu Its also nice to add casual social open-end segment to the end of the workshop. So people can already go into personal conversations, music and beverages while some last nodes sync up, confirmations come in and people sending their first satoshis on some lightning chess or from node to node. +Here are some videos that show what else is possible with the RaspiBlitz: +- [Lightning Network LND API - Buying Stickers using Commandline](https://youtu.be/tocJFPU8sAc) 24min + # Organisation Tasks *Which of the follwoing organisation tasks are relevant for you depends on which starting scenario you choose (see above). Here is the complete possible list with details:* From ea20f51f0a21957a83ab3f8243d5e5b4c9a9169b Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 01:15:57 +0100 Subject: [PATCH 010/162] formatted seed words --- home.admin/70initLND.sh | 4 ++-- home.admin/config.scripts/lnd.initwallet.py | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index b7c6b6e..6cd5f64 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -187,8 +187,8 @@ if [ ${walletExists} -eq 0 ]; then ack=0 while [ ${ack} -eq 0 ] do - whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:" 8 76 - whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?\n${seedwords}" 8 55 + whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n${seedwords}" 8 76 + whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55 if [ $? -eq 1 ]; then ack=1 fi diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index 1edc11f..6b91a19 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -57,15 +57,24 @@ channel = grpc.secure_channel('localhost:10009', ssl_creds) stub = lnrpc.WalletUnlockerStub(channel) if mode=="new": - #request = ln.GenSeedRequest( - # aezeed_passphrase= - #) request = ln.GenSeedRequest() try: response = stub.GenSeed(request) seedwords = response.cipher_seed_mnemonic seedwordsString=','.join(seedwords) print("seedwords='"+seedwordsString+"'") + + # add a 6x4 formatted version to the output + seedwords6x4="" + for i in range(0,len(seedwords)): + if (i % 6 == 0) && (i != 0): + seedwords6x4=seedwords6x4+"\n" + singleWord=(i+1)+":"+seedwords[i] + while len(singleWord)<12 + singleWord=singleWord+" " + seedwords6x4=seedwords6x4+singleWord + print("seedwords6x4='"+seedwords6x4+"'") + except grpc.RpcError as err: # - wallet might already exist print("err='grpc.RpcError'") @@ -76,12 +85,6 @@ if mode=="new": print >> sys.stderr, err sys.exit(1) - # TODO: do first https://api.lightning.community/#genseed - - #if len(seedpassword)>0: - # request = ln.InitWalletRequest(wallet_password=base64.b64encode(walletpassword.decode(),aezeed_passphrase=base64.b64encode(seedpassword).decode()) - #else: - request = ln.InitWalletRequest( wallet_password=walletpassword, cipher_seed_mnemonic=seedwords From f8e4323b6b3160b0183760b055dbd290ab537cb6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 01:25:02 +0100 Subject: [PATCH 011/162] fix formatting --- home.admin/config.scripts/lnd.initwallet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index 6b91a19..ad18d09 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -67,10 +67,10 @@ if mode=="new": # add a 6x4 formatted version to the output seedwords6x4="" for i in range(0,len(seedwords)): - if (i % 6 == 0) && (i != 0): + if i % 6 == 0 and i != 0: seedwords6x4=seedwords6x4+"\n" - singleWord=(i+1)+":"+seedwords[i] - while len(singleWord)<12 + singleWord=str(i+1)+":"+seedwords[i] + while len(singleWord)<12: singleWord=singleWord+" " seedwords6x4=seedwords6x4+singleWord print("seedwords6x4='"+seedwords6x4+"'") From 661e4600cd7f35b9937a289cfb3d6da4e357561a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 01:33:29 +0100 Subject: [PATCH 012/162] show formatted seed word list --- home.admin/70initLND.sh | 7 ++++--- home.admin/config.scripts/lnd.initwallet.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 6cd5f64..42cf4d5 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -181,13 +181,14 @@ if [ ${walletExists} -eq 0 ]; then fi fi - # TODO: create numbered string in rows - # 5 rows with 6 words each - each word needs to be filled up with spaces to be 12chars long -> (1:test ) + if [ ${#seedwords6x4} -eq 0 ]; then + seedwords6x4="${seedwords}" + fi ack=0 while [ ${ack} -eq 0 ] do - whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n${seedwords}" 8 76 + whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n${seedwords6x4}" 8 76 whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55 if [ $? -eq 1 ]; then ack=1 diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index ad18d09..6e90308 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -61,7 +61,7 @@ if mode=="new": try: response = stub.GenSeed(request) seedwords = response.cipher_seed_mnemonic - seedwordsString=','.join(seedwords) + seedwordsString=', '.join(seedwords) print("seedwords='"+seedwordsString+"'") # add a 6x4 formatted version to the output From bad94b8daa99e2153b43be770a4480fdb1a21b77 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 01:58:12 +0100 Subject: [PATCH 013/162] fix torrent after install --- home.admin/00infoBlitz.sh | 22 ++++++++++++---------- home.admin/50torrentHDD.sh | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index 1403456..ed21c40 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -273,16 +273,18 @@ fi # STATUS SINALING: Backup Torrent Seeding torrentBaseStatus="•" torrentUpdateStatus="•" -source <(sudo -u admin /home/admin/50torrentHDD.sh status) -if [ "${baseComplete}" == "1" ]; then - torrentBaseStatus="↑" -elif [ "${baseSeeding}" == "1" ]; then - torrentBaseStatus="↓" -fi -if [ "${updateComplete}" == "1" ]; then - torrentUpdateStatus="↑" -elif [ "${updateSeeding}" == "1" ]; then - torrentUpdateStatus="↓" +if [ "${backupTorrentSeeding}" == "on" ]; then + source <(sudo -u admin /home/admin/50torrentHDD.sh status) + if [ "${baseComplete}" == "1" ]; then + torrentBaseStatus="↑" + elif [ "${baseSeeding}" == "1" ]; then + torrentBaseStatus="↓" + fi + if [ "${updateComplete}" == "1" ]; then + torrentUpdateStatus="↑" + elif [ "${updateSeeding}" == "1" ]; then + torrentUpdateStatus="↓" + fi fi sleep 5 diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index f475050..a9d9f13 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -367,8 +367,8 @@ date +%s echo "can take 10-60 minutes... please wait" sudo mkdir /mnt/hdd/${network} 2>/dev/null sudo mv ${targetPath1}/* /mnt/hdd/${network}/ +sudo rm -r ${sessionDir}/blockchain sudo cp --verbose -r ${targetPath2}/* /mnt/hdd/${network}/ -sudo rm -r ${targetDir} echo "OK" date +%s From 8a009d2be6f8ab9e46ea7cfbb6c3c7599b42f2b7 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 02:02:18 +0100 Subject: [PATCH 014/162] fix dialog --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 42cf4d5..51c1277 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -188,7 +188,7 @@ if [ ${walletExists} -eq 0 ]; then ack=0 while [ ${ack} -eq 0 ] do - whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n${seedwords6x4}" 8 76 + whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n${seedwords6x4}" 12 76 whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55 if [ $? -eq 1 ]; then ack=1 From ea1a21e5fdf64edf5bae0556ce614cd4a45218ec Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 02:03:08 +0100 Subject: [PATCH 015/162] UI info --- home.admin/70initLND.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 51c1277..e38a838 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -161,6 +161,7 @@ if [ ${walletExists} -eq 0 ]; then fi # generate wallet with seed and set passwordC + echo "Generating new Wallet ...." source /home/admin/python-env-lnd/bin/activate python /home/admin/config.scripts/lnd.initwallet.py new ${passwordC} > /home/admin/.seed.tmp source /home/admin/.seed.tmp From fbec65fac1f117220cf142bcf507bb8f1dcd92ca Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 02:05:58 +0100 Subject: [PATCH 016/162] UI fixes --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index e38a838..5d6953a 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -189,7 +189,7 @@ if [ ${walletExists} -eq 0 ]; then ack=0 while [ ${ack} -eq 0 ] do - whiptail --title "IMPORTANT - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n${seedwords6x4}" 12 76 + whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n\n${seedwords6x4}" 12 76 whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55 if [ $? -eq 1 ]; then ack=1 From 0d969cbb68b2155f5a6f08b2cf6438bb5a85c6c1 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 02:25:24 +0100 Subject: [PATCH 017/162] torrent add stop --- home.admin/50torrentHDD.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index a9d9f13..02dfe07 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -40,7 +40,7 @@ targetDir="/mnt/hdd/torrent" sessionDir="/home/admin/.rtorrent.session" # BACKUP TORRENT SEEDING -if [ "$1" == "cleanup" ]; then +if [ "$1" == "stop" ] || [ "$1" == "cleanup" ]; then echo "Stopping Torrents ..." sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) if [ ${#sessionPID} -gt 0 ]; then @@ -50,6 +50,20 @@ if [ "$1" == "cleanup" ]; then if [ ${#sessionPID} -gt 0 ]; then sudo pkill -P ${sessionPID} fi +fi +if [ "$1" == "stop" ] || [ "$1" == "cleanup" ]; then + echo "Stopping Torrents ..." + sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs) + if [ ${#sessionPID} -gt 0 ]; then + sudo pkill -P ${sessionPID} + fi + sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs) + if [ ${#sessionPID} -gt 0 ]; then + sudo pkill -P ${sessionPID} + fi + if [ "$1" == "stop" ]; then + exit 0 + fi echo "Deleting all possible old (version) torrent data ..." sudo rm -r /home/admin/.rtorrent.session 2>/dev/null sudo rm -r /mnt/hdd/torrent 2>/dev/null From 08b3432bd309412b1a066b825d4dbfa6ed25f23f Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 12:31:28 +0100 Subject: [PATCH 018/162] LND MONITOR LOST SYNC --- home.admin/50torrentHDD.sh | 3 ++ home.admin/_background.sh | 92 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 02dfe07..8395874 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -11,6 +11,9 @@ # status # to get info backround torrent hosting + +# stop +# just stopping the download - not switching off ## get basic info source /home/admin/raspiblitz.info diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 6314939..98fa48f 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -22,6 +22,10 @@ fi echo "_background.sh STARTED" +# monitor lost LND sync +syncedSince=0 +lastSyncState=0 + counter=0 while [ 1 ] do @@ -146,6 +150,94 @@ do fi + + ############################### + # LND MONITOR LOST SYNC + ############################### + + # check every 5min + recheckSync=$(($counter % 300)) + if [ ${recheckSync} -eq 1 ]; then + source ${configFile} + echo "LND MONITOR LOST SYNC ..." + lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) + echo "lndSynced(${lndSynced})" + echo "syncedSince(${syncedSince})" + echo "lastSyncState(${lastSyncState})" + if [ ${lndSynced} -eq ${lastSyncState} ]; then + + echo "no sync change" + if [ ${lndSynced} -eq 1 ]; then + echo "all is good - LND still in sync now for:" + actualSecondsTimestamp=$(date +%s) + secondsInSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) + echo "${secondsInSync} seconds" + if [ "${backupTorrentSeeding}" == "on" ]; then + echo "Backup Torrent Seeding is ON - check if already running" + source <(sudo -u admin /home/admin/50torrentHDD.sh status) + if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then + echo "---> STARTING Backup Torrent Seeding" + sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting + else + echo "Backup Torrent Seeding - already running" + fi + else + echo "Backup Torrent Seeding is OFF" + fi + else + echo "still not in sync" + if [ ${syncedSince} -gt 0 ]; then + + echo "was in sync at least once since rinning but lost now for:" + actualSecondsTimestamp=$(date +%s) + secondsOutOfSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) + echo "${secondsOutOfSync} seconds" + + # when >10min out of sync + if [ ${secondsOutOfSync} -gt 600 ]; then + echo "! LND fell out of sync for longer then 10 minutes !" + if [ "${backupTorrentSeeding}" == "on" ]; then + echo "Backup Torrent Seeding is ON - check if still running" + source <(sudo -u admin /home/admin/50torrentHDD.sh status) + if [ "${baseSeeding}" == "1" ] || [ "${updateSeeding}" == "1" ]; then + echo "---> STOPPING Backup Torrent Seeding" + sudo -u admin /home/admin/50torrentHDD.sh stop + else + echo "No Backup Torrent Seeding - already stopped" + fi + else + echo "Backup Torrent Seeding is OFF" + fi + fi + + # when >1h out of sync + if [ ${secondsOutOfSync} -gt 3600 ]; then + echo "!!!! LND fell out of sync for longer then 1 hour !!!" + # TODO: When auto-unlock is ON --> consider implementing restart (this sometimes help) + fi + + else + echo "LND was never in sync since since started (could be multiple reasons - dont act)" + fi + fi + + else + echo "sync change detected" + if [ ${lastSyncState} -eq 1 ] && [ ${lndSynced} -eq 0 ]; then + echo "--> LND SNC LOST" + else + if [ ${syncedSince} -eq 0 ]; then + echo "--> LND SYNC GAINED" + else + echo "--> LND SYNC RECOVERED" + fi + syncedSince=$(date +%s) + fi + fi + + lastSyncState=${lastSyncState} + fi + ############################### # LND AUTO-UNLOCK ############################### From 3f9719b1b41db89275bfb8e7e4aa8c1877accde6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 12:34:14 +0100 Subject: [PATCH 019/162] background task controls torrent --- home.admin/_background.sh | 26 ++++++++++++++++---------- home.admin/_bootstrap.sh | 9 --------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 98fa48f..c94e396 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -172,22 +172,28 @@ do actualSecondsTimestamp=$(date +%s) secondsInSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) echo "${secondsInSync} seconds" - if [ "${backupTorrentSeeding}" == "on" ]; then - echo "Backup Torrent Seeding is ON - check if already running" - source <(sudo -u admin /home/admin/50torrentHDD.sh status) - if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then - echo "---> STARTING Backup Torrent Seeding" - sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting + + # when >10min in sync + if [ ${secondsInSync} -gt 600 ]; then + echo "LND in sync for longer then 10 minutes" + if [ "${backupTorrentSeeding}" == "on" ]; then + echo "Backup Torrent Seeding is ON - check if already running" + source <(sudo -u admin /home/admin/50torrentHDD.sh status) + if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then + echo "---> STARTING Backup Torrent Seeding" + sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting + else + echo "Backup Torrent Seeding - already running" + fi else - echo "Backup Torrent Seeding - already running" + echo "Backup Torrent Seeding is OFF" fi - else - echo "Backup Torrent Seeding is OFF" fi + else echo "still not in sync" if [ ${syncedSince} -gt 0 ]; then - + echo "was in sync at least once since rinning but lost now for:" actualSecondsTimestamp=$(date +%s) secondsOutOfSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index acc4956..078fd6a 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -435,14 +435,5 @@ sed -i "s/^state=.*/state=stresstest/g" ${infoFile} sed -i "s/^message=.*/message='Testing Hardware 60s'/g" ${infoFile} sudo /home/admin/config.scripts/blitz.stresstest.sh /home/admin/stresstest.report -################################ -# BACKUP TORRENT SEEDING -################################ - -if [ "${backupTorrentSeeding}" == "on" ]; then - echo "Starting BACKUP TORRENT HOSTING in background (after 6 hours) ..." >> $logFile - ( sleep 6h ; sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting ) & -fi - echo "DONE BOOTSTRAP" >> $logFile exit 0 \ No newline at end of file From 7ee85de6944459667bf14ded6f2c75fb910df706 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 13:10:41 +0100 Subject: [PATCH 020/162] fix last state update --- home.admin/_background.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index c94e396..bb4c95a 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -189,7 +189,7 @@ do echo "Backup Torrent Seeding is OFF" fi fi - + else echo "still not in sync" if [ ${syncedSince} -gt 0 ]; then @@ -241,7 +241,7 @@ do fi fi - lastSyncState=${lastSyncState} + lastSyncState=${lndSynced} fi ############################### From 4d60642f0e8d141b27f4543f635f173cf37ab450 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 13:11:59 +0100 Subject: [PATCH 021/162] reduce copy info on sync --- home.admin/XXsyncScripts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/XXsyncScripts.sh b/home.admin/XXsyncScripts.sh index c865102..02fa0a7 100755 --- a/home.admin/XXsyncScripts.sh +++ b/home.admin/XXsyncScripts.sh @@ -61,7 +61,7 @@ else echo "******************************************" fi echo "COPYING from GIT-Directory to /home/admin/ .." -sudo -u admin cp --verbose -r -f /home/admin/raspiblitz/home.admin/*.* /home/admin +sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/*.* /home/admin sudo -u admin chmod +x /home/admin/*.sh sudo -u admin chmod +x /home/admin/*.py sudo -u admin chmod +x /home/admin/config.scripts/*.sh From a0864e37a47fc5814025740c43174944b608625e Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 13:37:20 +0100 Subject: [PATCH 022/162] dont show if torrent backup is off --- home.admin/00infoBlitz.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index ed21c40..5bd996f 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -271,9 +271,11 @@ else fi # STATUS SINALING: Backup Torrent Seeding -torrentBaseStatus="•" -torrentUpdateStatus="•" +torrentBaseStatus="" +torrentUpdateStatus="" if [ "${backupTorrentSeeding}" == "on" ]; then + torrentBaseStatus="•" + torrentUpdateStatus="•" source <(sudo -u admin /home/admin/50torrentHDD.sh status) if [ "${baseComplete}" == "1" ]; then torrentBaseStatus="↑" From 6e1af3a3a061ab1c5227248dba44f9a185b6debb Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 14:59:53 +0100 Subject: [PATCH 023/162] #437 basic background backup script --- home.admin/_background.sh | 69 +++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index bb4c95a..33beaf6 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -151,6 +151,33 @@ do fi + ############################### + # SCB Monitoring + ############################### + + # check every 1min + recheckSCB=$(($counter % 60)) + if [ ${recheckSCB} -eq 1 ]; then + echo "SCB Monitoring ..." + # check if channel.backup exists + scbExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | grep -c 'channel.backup') + if [ ${scbExists} -eq 1 ]; then + echo "Found Channel Backup File .. check if changed .." + md5checksumORG=$(sudo md5sum /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) + md5checksumCPY=$(sudo md5sum /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) + if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then + echo "--> Channel Backup File changed" + sudo mkdir -p /home/admin/.lnd/data/chain/${network}/${chain}net/ 2>/dev/null + sudp cp /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup + echo "OK channel.backup copied to '/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup'" + else + echo "Channel Backup File not changed." + fi + else + echo "No Channel Backup File .." + fi + fi + ############################### # LND MONITOR LOST SYNC ############################### @@ -159,78 +186,78 @@ do recheckSync=$(($counter % 300)) if [ ${recheckSync} -eq 1 ]; then source ${configFile} - echo "LND MONITOR LOST SYNC ..." + #echo "LND MONITOR LOST SYNC ..." lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) - echo "lndSynced(${lndSynced})" - echo "syncedSince(${syncedSince})" - echo "lastSyncState(${lastSyncState})" + #echo "lndSynced(${lndSynced})" + #echo "syncedSince(${syncedSince})" + #echo "lastSyncState(${lastSyncState})" if [ ${lndSynced} -eq ${lastSyncState} ]; then echo "no sync change" if [ ${lndSynced} -eq 1 ]; then - echo "all is good - LND still in sync now for:" + #echo "all is good - LND still in sync now for:" actualSecondsTimestamp=$(date +%s) secondsInSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) - echo "${secondsInSync} seconds" + #echo "${secondsInSync} seconds" # when >10min in sync - if [ ${secondsInSync} -gt 600 ]; then - echo "LND in sync for longer then 10 minutes" + if [ ${secondsInSync} -gt 3600 ]; then + #echo "LND in sync for longer then 1 hour" if [ "${backupTorrentSeeding}" == "on" ]; then - echo "Backup Torrent Seeding is ON - check if already running" + #echo "Backup Torrent Seeding is ON - check if already running" source <(sudo -u admin /home/admin/50torrentHDD.sh status) if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then echo "---> STARTING Backup Torrent Seeding" sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting else - echo "Backup Torrent Seeding - already running" + #echo "Backup Torrent Seeding - already running" fi else - echo "Backup Torrent Seeding is OFF" + #echo "Backup Torrent Seeding is OFF" fi fi else - echo "still not in sync" + #echo "still not in sync" if [ ${syncedSince} -gt 0 ]; then - echo "was in sync at least once since rinning but lost now for:" + #echo "was in sync at least once since rinning but lost now for:" actualSecondsTimestamp=$(date +%s) secondsOutOfSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) - echo "${secondsOutOfSync} seconds" + #echo "${secondsOutOfSync} seconds" # when >10min out of sync if [ ${secondsOutOfSync} -gt 600 ]; then - echo "! LND fell out of sync for longer then 10 minutes !" + #echo "! LND fell out of sync for longer then 10 minutes !" if [ "${backupTorrentSeeding}" == "on" ]; then - echo "Backup Torrent Seeding is ON - check if still running" + #echo "Backup Torrent Seeding is ON - check if still running" source <(sudo -u admin /home/admin/50torrentHDD.sh status) if [ "${baseSeeding}" == "1" ] || [ "${updateSeeding}" == "1" ]; then echo "---> STOPPING Backup Torrent Seeding" sudo -u admin /home/admin/50torrentHDD.sh stop else - echo "No Backup Torrent Seeding - already stopped" + #echo "No Backup Torrent Seeding - already stopped" fi else - echo "Backup Torrent Seeding is OFF" + #echo "Backup Torrent Seeding is OFF" fi fi # when >1h out of sync if [ ${secondsOutOfSync} -gt 3600 ]; then - echo "!!!! LND fell out of sync for longer then 1 hour !!!" + # echo "!!!! LND fell out of sync for longer then 1 hour !!!" # TODO: When auto-unlock is ON --> consider implementing restart (this sometimes help) fi else - echo "LND was never in sync since since started (could be multiple reasons - dont act)" + #echo "LND was never in sync since since started (could be multiple reasons - dont act)" fi fi else echo "sync change detected" if [ ${lastSyncState} -eq 1 ] && [ ${lndSynced} -eq 0 ]; then - echo "--> LND SNC LOST" + echo "--> LND SYNC LOST" else if [ ${syncedSince} -eq 0 ]; then echo "--> LND SYNC GAINED" From df6c45fb29f753c5b0061d46e6b9581da2c9aea9 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 16:04:39 +0100 Subject: [PATCH 024/162] #437 test dropbox script (no third party libs) --- home.admin/config.scripts/dropbox.upload.sh | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 home.admin/config.scripts/dropbox.upload.sh diff --git a/home.admin/config.scripts/dropbox.upload.sh b/home.admin/config.scripts/dropbox.upload.sh new file mode 100644 index 0000000..358eb60 --- /dev/null +++ b/home.admin/config.scripts/dropbox.upload.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "# script to upload a file to DropBox (without third party libs)" + echo "# dropbox.upload.sh upload [AUTHTOKEN] [FILEPATH]" + echo "# dropbox.upload.sh check [AUTHTOKEN]" + echo "# for Dropbox Setup with Authtoken, see:" + echo "# https://gist.github.com/vindard/e0cd3d41bb403a823f3b5002488e3f90" + echo "err='just informational output'" + exit 1 +fi + +# get first parameter +MODE="$1" +if [ "${MODE}" == "check" ]; then + + # get needed second parameter + DROPBOX_APITOKEN="$2" + if [ ${#DROPBOX_APITOKEN} -eq 0 ]; then + echo "err='missing Parameter AUTHTOKEN'" + exit 1 + fi + + # run API check + curl -s -X POST https://api.dropboxapi.com/2/users/get_current_account \ + --header "Authorization: Bearer "$DROPBOX_APITOKEN | grep rror + if [[ ! $? -eq 0 ]] ; then + echo "# Dropbox API Token worked" + echo "check=1" + else + echo "# Invalid Dropbox API Token!" + echo "check=0" + fi + +elif [ "${MODE}" == "upload" ]; then + + # get needed second parameter + DROPBOX_APITOKEN="$2" + if [ ${#DROPBOX_APITOKEN} -eq 0 ]; then + echo "err='missing Parameter AUTHTOKEN'" + exit 1 + fi + + # get needed third parameter + SOURCEFILE="$3" + if [ ${#SOURCEFILE} -eq 0 ]; then + echo "err='missing Parameter SOURCEFILE'" + exit 1 + fi + + FINISH=$(curl -s -X POST https://content.dropboxapi.com/2/files/upload \ + --header "Authorization: Bearer "${DROPBOX_APITOKEN}"" \ + --header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$1"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ + --header "Content-Type: application/octet-stream" \ + --data-binary @$1) + echo "finish($FINISH)" + UPLOADTIME=$(echo $FINISH | jq -r .server_modified) + if [ ! -z $UPLOADTIME ] ; then + echo "Successfully uploaded!" + else + echo "err='unknown error when uploading'" + fi + +else + echo "err='unkown mode'" + exit 1 +fi + + + + + + + + + From 1c6ce85e46ea1337d4b7bf74cd78a30bdac59919 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 16:42:13 +0100 Subject: [PATCH 025/162] deactivate autoinstall bonus scripts --- home.admin/90finishSetup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/90finishSetup.sh b/home.admin/90finishSetup.sh index 92986de..783df94 100755 --- a/home.admin/90finishSetup.sh +++ b/home.admin/90finishSetup.sh @@ -1,8 +1,8 @@ #!/bin/bash echo "" -# add bonus scripts -/home/admin/91addBonus.sh +# add bonus scripts (auto install deactivated to reduce third party repos) +# /home/admin/91addBonus.sh ###### SWAP & FS echo "" From 1dd09cc7bccfa850b05cbaf10fb13d3c7f507759 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 16:42:24 +0100 Subject: [PATCH 026/162] fix dropbox upload --- home.admin/config.scripts/dropbox.upload.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/home.admin/config.scripts/dropbox.upload.sh b/home.admin/config.scripts/dropbox.upload.sh index 358eb60..e51586b 100644 --- a/home.admin/config.scripts/dropbox.upload.sh +++ b/home.admin/config.scripts/dropbox.upload.sh @@ -49,17 +49,24 @@ elif [ "${MODE}" == "upload" ]; then exit 1 fi - FINISH=$(curl -s -X POST https://content.dropboxapi.com/2/files/upload \ + DEVICE=$(echo $DEVICE | awk '{print tolower($0)}' | sed -e 's/ /-/g') + BACKUPFOLDER=.lndbackup-$DEVICE + + curl -s -X POST https://content.dropboxapi.com/2/files/upload \ --header "Authorization: Bearer "${DROPBOX_APITOKEN}"" \ --header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$1"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ --header "Content-Type: application/octet-stream" \ - --data-binary @$1) - echo "finish($FINISH)" + --data-binary @$1 > /home/admin/.dropbbox.tmp + safeResponse=$(sed 's/[^a-zA-Z0-9 ]//g' /home/admin/.dropbbox.tmp) + sudo shred /home/admin/.dropbbox.tmp UPLOADTIME=$(echo $FINISH | jq -r .server_modified) if [ ! -z $UPLOADTIME ] ; then - echo "Successfully uploaded!" + echo "# Successfully uploaded!" + echo "upload=1" else - echo "err='unknown error when uploading'" + echo "# Unknown Error" + echo "upload=0" + echo "err='${safeResponse}'" fi else From b614a879b0c4879bd7bfc6ffb9a3f044dce45de6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 16:46:07 +0100 Subject: [PATCH 027/162] debug output --- home.admin/config.scripts/dropbox.upload.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/home.admin/config.scripts/dropbox.upload.sh b/home.admin/config.scripts/dropbox.upload.sh index e51586b..d71d390 100644 --- a/home.admin/config.scripts/dropbox.upload.sh +++ b/home.admin/config.scripts/dropbox.upload.sh @@ -56,9 +56,10 @@ elif [ "${MODE}" == "upload" ]; then --header "Authorization: Bearer "${DROPBOX_APITOKEN}"" \ --header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$1"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ --header "Content-Type: application/octet-stream" \ - --data-binary @$1 > /home/admin/.dropbbox.tmp - safeResponse=$(sed 's/[^a-zA-Z0-9 ]//g' /home/admin/.dropbbox.tmp) - sudo shred /home/admin/.dropbbox.tmp + --data-binary @$1 > /home/admin/.dropbox.tmp + safeResponse=$(sed 's/[^a-zA-Z0-9 ]//g' /home/admin/.dropbox.tmp) + #sudo shred /home/admin/.dropbox.tmp + #sudo rm /home/admin/.dropbox.tmp 2>/dev/null UPLOADTIME=$(echo $FINISH | jq -r .server_modified) if [ ! -z $UPLOADTIME ] ; then echo "# Successfully uploaded!" From fc56b4ddf0b38f11959bcac665a7712f9409a489 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 16:58:46 +0100 Subject: [PATCH 028/162] fix dropbox upload --- home.admin/config.scripts/dropbox.upload.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/home.admin/config.scripts/dropbox.upload.sh b/home.admin/config.scripts/dropbox.upload.sh index d71d390..d73994b 100644 --- a/home.admin/config.scripts/dropbox.upload.sh +++ b/home.admin/config.scripts/dropbox.upload.sh @@ -52,16 +52,16 @@ elif [ "${MODE}" == "upload" ]; then DEVICE=$(echo $DEVICE | awk '{print tolower($0)}' | sed -e 's/ /-/g') BACKUPFOLDER=.lndbackup-$DEVICE - curl -s -X POST https://content.dropboxapi.com/2/files/upload \ + sudo curl -s -X POST https://content.dropboxapi.com/2/files/upload \ --header "Authorization: Bearer "${DROPBOX_APITOKEN}"" \ --header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$1"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ --header "Content-Type: application/octet-stream" \ --data-binary @$1 > /home/admin/.dropbox.tmp safeResponse=$(sed 's/[^a-zA-Z0-9 ]//g' /home/admin/.dropbox.tmp) - #sudo shred /home/admin/.dropbox.tmp - #sudo rm /home/admin/.dropbox.tmp 2>/dev/null - UPLOADTIME=$(echo $FINISH | jq -r .server_modified) - if [ ! -z $UPLOADTIME ] ; then + success=$(echo "${safeResponse}" | grep -c 'servermodified') + sudo shred /home/admin/.dropbox.tmp + sudo rm /home/admin/.dropbox.tmp 2>/dev/null + if [ ${success} -gt 0 ] ; then echo "# Successfully uploaded!" echo "upload=1" else From 16b1a7150f1d9f4e317c618e789ecc13def247e9 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 17:10:15 +0100 Subject: [PATCH 029/162] fix dropbox upload --- home.admin/config.scripts/dropbox.upload.sh | 26 ++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/home.admin/config.scripts/dropbox.upload.sh b/home.admin/config.scripts/dropbox.upload.sh index d73994b..d33dc7e 100644 --- a/home.admin/config.scripts/dropbox.upload.sh +++ b/home.admin/config.scripts/dropbox.upload.sh @@ -49,25 +49,39 @@ elif [ "${MODE}" == "upload" ]; then exit 1 fi - DEVICE=$(echo $DEVICE | awk '{print tolower($0)}' | sed -e 's/ /-/g') + source /mnt/hdd/raspiblitz.conf + if [ ${#hostname} -eq 0 ]; then + hostname="raspiblitz" + fi + + DEVICE=$(echo "${hostname}" | awk '{print tolower($0)}' | sed -e 's/ /-/g') BACKUPFOLDER=.lndbackup-$DEVICE + FILENAME=$(basename "${SOURCEFILE}") sudo curl -s -X POST https://content.dropboxapi.com/2/files/upload \ --header "Authorization: Bearer "${DROPBOX_APITOKEN}"" \ - --header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$1"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ + --header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$FILENAME"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ --header "Content-Type: application/octet-stream" \ - --data-binary @$1 > /home/admin/.dropbox.tmp + --data-binary @$SOURCEFILE > /home/admin/.dropbox.tmp safeResponse=$(sed 's/[^a-zA-Z0-9 ]//g' /home/admin/.dropbox.tmp) - success=$(echo "${safeResponse}" | grep -c 'servermodified') sudo shred /home/admin/.dropbox.tmp sudo rm /home/admin/.dropbox.tmp 2>/dev/null - if [ ${success} -gt 0 ] ; then + + success=$(echo "${safeResponse}" | grep -c 'servermodified') + sizeZero=$(echo "${safeResponse}" | grep -c 'size 0') + if [ ${sizeZero} -gt 0 ]; then + echo "# Upload happened but is size zero" + echo "upload=0" + echo "err='size zero'" + echo "errMore='${safeResponse}'" + elif [ ${success} -gt 0 ] ; then echo "# Successfully uploaded!" echo "upload=1" else echo "# Unknown Error" echo "upload=0" - echo "err='${safeResponse}'" + echo "err='unknown'" + echo "errMore='${safeResponse}'" fi else From 4cae70b410add1774f9ca3e8ef017ff927fb6c2c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 18:45:16 +0100 Subject: [PATCH 030/162] #437 OffSite SCBs with SCP & Dropbox --- home.admin/_background.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 33beaf6..397ce0e 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -159,6 +159,7 @@ do recheckSCB=$(($counter % 60)) if [ ${recheckSCB} -eq 1 ]; then echo "SCB Monitoring ..." + source ${configFile} # check if channel.backup exists scbExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | grep -c 'channel.backup') if [ ${scbExists} -eq 1 ]; then @@ -167,9 +168,38 @@ do md5checksumCPY=$(sudo md5sum /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then echo "--> Channel Backup File changed" + + # make copy to sd card (as local basic backup) sudo mkdir -p /home/admin/.lnd/data/chain/${network}/${chain}net/ 2>/dev/null sudp cp /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup echo "OK channel.backup copied to '/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup'" + + # check if a SCP backup target is set + # paramter in raspiblitz.conf: + # scpBackupTarget='[USER]@s[SERVER]:[DIRPATH-WITHOUT-ENDING-/]' + # On target server add the public key of your RaspiBlitz to the authorized_keys for the user + # https://www.linode.com/docs/security/authentication/use-public-key-authentication-with-ssh/ + if [ ${#scpBackupTarget} -gt 0 ]; then + echo "--> Offsite-Backup SCP Server" + result=$(sudo scp /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup) + echo "result(${result})" + fi + + # check if a DropBox backup target is set + # paramter in raspiblitz.conf: + # dropboxBackupTarget='[DROPBOX-APP-OAUTH2-TOKEN]' + # see dropbox setup: https://gist.github.com/vindard/e0cd3d41bb403a823f3b5002488e3f90 + if [ ${#dropboxBackupTarget} -gt 0 ]; then + echo "--> Offsite-Backup Dropbox" + source <(sudo /home/admin/config.scripts/dropbox.upload.sh upload ${dropboxBackupTarget} /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup) + if [ ${#err} -gt 0 ]; then + echo "FAIL: ${err}" + echo "${errMore}" + else + echo "OK: ${upload}" + fi + fi + else echo "Channel Backup File not changed." fi From 890b9bfdef10ea748005b49011e6ee8facf0a2ee Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 18:57:54 +0100 Subject: [PATCH 031/162] remove empty else blocks --- home.admin/_background.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 397ce0e..66591d2 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -239,11 +239,7 @@ do if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then echo "---> STARTING Backup Torrent Seeding" sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting - else - #echo "Backup Torrent Seeding - already running" fi - else - #echo "Backup Torrent Seeding is OFF" fi fi @@ -265,11 +261,7 @@ do if [ "${baseSeeding}" == "1" ] || [ "${updateSeeding}" == "1" ]; then echo "---> STOPPING Backup Torrent Seeding" sudo -u admin /home/admin/50torrentHDD.sh stop - else - #echo "No Backup Torrent Seeding - already stopped" fi - else - #echo "Backup Torrent Seeding is OFF" fi fi @@ -278,9 +270,7 @@ do # echo "!!!! LND fell out of sync for longer then 1 hour !!!" # TODO: When auto-unlock is ON --> consider implementing restart (this sometimes help) fi - - else - #echo "LND was never in sync since since started (could be multiple reasons - dont act)" + fi fi From 9644389e8c6642ac1a2975db28e03e948f3aa3cd Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 19:17:17 +0100 Subject: [PATCH 032/162] #497 New Sweep All Coins Command of LND 0.6 --- home.admin/BBcashoutWallet.sh | 79 ++++++++++++----------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index 5766b29..f90bc2e 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -24,6 +24,7 @@ if [ ${#openChannels} -eq 0 ]; then 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 echo "please wait ..." @@ -45,10 +46,10 @@ fi # let user enter the address l1="Enter on-chain address to send confirmed funds to:" -l2="You will send: ${maxAmount} sat" -l3="Maximal fee: 20000 sat (wil be subtracted)" +#l2="You will send: ${maxAmount} sat" +#l3="Maximal fee: 20000 sat (wil be subtracted)" dialog --title "Where to send funds?" \ ---inputbox "$l1\n$l2\n$l3" 9 75 2>$_temp +--inputbox "\n$l1\n" 9 75 2>$_temp if test $? -eq 0 then echo "ok pressed" @@ -63,60 +64,32 @@ if [ ${#address} -eq 0 ]; then exit 1 fi -# TODO: check address is valid for network and chain - clear echo "******************************" echo "Send on-chain Funds" echo "******************************" -tryAgain=1 -count=1 -while [ ${tryAgain} -eq 1 ] - do - sleep 1 - fee=$(($count * 1000)) - amount=$(($maxAmount - $fee)) - echo "" - echo "TRY #${count} ---> with max fee ${fee} sat:" - # execute command - command="lncli --chain=${network} --network=${chain}net sendcoins --addr ${address} --amt ${amount} --conf_target 3" - echo "$command" - result=$($command 2>$_error) - error=`cat ${_error}` - #error="sim error: insufficient funds available to construct transaction" - #result="" - - if [ ${#result} -eq 0 ]; then - # fail - retry on 'insufficient funds available to construct transaction' - echo "FAIL: $error" - tryAgain=$(echo "${error}" | grep -c 'insufficient funds available to construct transaction') - if [ ${tryAgain} -eq 0 ]; then - echo "" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "FINAL FAIL --> Was not able to send transaction (see error above)" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - fi - else - # success - echo "$result" - echo "" - echo "********************************************************************" - echo "OK --> send ${amount} sat to address + ${fee} sat fees max" - echo "********************************************************************" - tryAgain=0 - fi +# execute command +command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --addr=${address} --conf_target=3" +echo "$command" +result=$($command 2>$_error) +error=`cat ${_error}` - # abort aftzer 20 tries - count=$(($count + 1)) - if [ ${count} -gt 20 ]; then - echo "" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "FINAL FAIL --> Was not able to send transaction with max 20000 sat" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - tryAgain=0 - fi - - done -exit 1 +if [ ${#result} -eq 0 ]; then + # fail - retry on 'insufficient funds available to construct transaction' + echo "FAIL: $error" + tryAgain=$(echo "${error}" | grep -c 'insufficient funds available to construct transaction') + if [ ${tryAgain} -eq 0 ]; then + echo "" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "FINAL FAIL --> Was not able to send transaction (see error above)" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + else + # success + echo "$result" + echo "" + echo "********************************************************************" + echo "OK --> to address ${address}" + echo "********************************************************************" + fi echo "" From 11445bd12a2acec03ac103b938ad563cd9704881 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 19:19:31 +0100 Subject: [PATCH 033/162] remove empty else --- home.admin/_background.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 66591d2..5f47109 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -266,10 +266,10 @@ do fi # when >1h out of sync - if [ ${secondsOutOfSync} -gt 3600 ]; then - # echo "!!!! LND fell out of sync for longer then 1 hour !!!" - # TODO: When auto-unlock is ON --> consider implementing restart (this sometimes help) - fi + #if [ ${secondsOutOfSync} -gt 3600 ]; then + # echo "!!!! LND fell out of sync for longer then 1 hour !!!" + # TODO: When auto-unlock is ON --> consider implementing restart (this sometimes help) + #fi fi fi From 930b9d1003872392b4fa330c8ad0aaf973fd1dc6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 19:27:42 +0100 Subject: [PATCH 034/162] fix dopy to sd card --- home.admin/_background.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 5f47109..8f54b55 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -171,7 +171,7 @@ do # make copy to sd card (as local basic backup) sudo mkdir -p /home/admin/.lnd/data/chain/${network}/${chain}net/ 2>/dev/null - sudp cp /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup + sudo cp /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup echo "OK channel.backup copied to '/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup'" # check if a SCP backup target is set From f91f832bfe357956cd253897a490506bfe624b9c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 19:28:43 +0100 Subject: [PATCH 035/162] add more debug --- home.admin/_background.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 8f54b55..3f59abf 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -182,6 +182,7 @@ do if [ ${#scpBackupTarget} -gt 0 ]; then echo "--> Offsite-Backup SCP Server" result=$(sudo scp /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup) + echo $? echo "result(${result})" fi From 8dc06603a27e9d7237c47b19e4280974a69fe9e7 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 19:37:41 +0100 Subject: [PATCH 036/162] #437 works - remove debug --- home.admin/_background.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 3f59abf..ffbdbef 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -158,12 +158,12 @@ do # check every 1min recheckSCB=$(($counter % 60)) if [ ${recheckSCB} -eq 1 ]; then - echo "SCB Monitoring ..." + #echo "SCB Monitoring ..." source ${configFile} # check if channel.backup exists scbExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | grep -c 'channel.backup') if [ ${scbExists} -eq 1 ]; then - echo "Found Channel Backup File .. check if changed .." + #echo "Found Channel Backup File .. check if changed .." md5checksumORG=$(sudo md5sum /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) md5checksumCPY=$(sudo md5sum /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then @@ -181,9 +181,13 @@ do # https://www.linode.com/docs/security/authentication/use-public-key-authentication-with-ssh/ if [ ${#scpBackupTarget} -gt 0 ]; then echo "--> Offsite-Backup SCP Server" - result=$(sudo scp /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup) - echo $? - echo "result(${result})" + sudo scp /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup + result=$? + if [ ${result} -eq 0 ]; then + echo "OK - SCP Backup exited with 0" + else + echo "FAIL - SCP Backup exited with ${result}" + fi fi # check if a DropBox backup target is set @@ -194,18 +198,18 @@ do echo "--> Offsite-Backup Dropbox" source <(sudo /home/admin/config.scripts/dropbox.upload.sh upload ${dropboxBackupTarget} /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup) if [ ${#err} -gt 0 ]; then - echo "FAIL: ${err}" + echo "FAIL - ${err}" echo "${errMore}" else - echo "OK: ${upload}" + echo "OK - ${upload}" fi fi - else - echo "Channel Backup File not changed." + #else + # echo "Channel Backup File not changed." fi - else - echo "No Channel Backup File .." + #else + # echo "No Channel Backup File .." fi fi @@ -224,7 +228,7 @@ do #echo "lastSyncState(${lastSyncState})" if [ ${lndSynced} -eq ${lastSyncState} ]; then - echo "no sync change" + #echo "no sync change" if [ ${lndSynced} -eq 1 ]; then #echo "all is good - LND still in sync now for:" actualSecondsTimestamp=$(date +%s) From d2134902c2e7482a39fe793622ccd555d45dfe6d Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 19:54:07 +0100 Subject: [PATCH 037/162] update doc --- home.admin/_background.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index ffbdbef..1bc602b 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -176,7 +176,7 @@ do # check if a SCP backup target is set # paramter in raspiblitz.conf: - # scpBackupTarget='[USER]@s[SERVER]:[DIRPATH-WITHOUT-ENDING-/]' + # scpBackupTarget='[USER]@[SERVER]:[DIRPATH-WITHOUT-ENDING-/]' # On target server add the public key of your RaspiBlitz to the authorized_keys for the user # https://www.linode.com/docs/security/authentication/use-public-key-authentication-with-ssh/ if [ ${#scpBackupTarget} -gt 0 ]; then From 5e47e0fb7f90f671b65e8f00548ee943c01ef516 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 20:58:29 +0100 Subject: [PATCH 038/162] stop background torrent when loosing sync --- home.admin/_background.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 1bc602b..6ae2763 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -257,19 +257,6 @@ do secondsOutOfSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) #echo "${secondsOutOfSync} seconds" - # when >10min out of sync - if [ ${secondsOutOfSync} -gt 600 ]; then - #echo "! LND fell out of sync for longer then 10 minutes !" - if [ "${backupTorrentSeeding}" == "on" ]; then - #echo "Backup Torrent Seeding is ON - check if still running" - source <(sudo -u admin /home/admin/50torrentHDD.sh status) - if [ "${baseSeeding}" == "1" ] || [ "${updateSeeding}" == "1" ]; then - echo "---> STOPPING Backup Torrent Seeding" - sudo -u admin /home/admin/50torrentHDD.sh stop - fi - fi - fi - # when >1h out of sync #if [ ${secondsOutOfSync} -gt 3600 ]; then # echo "!!!! LND fell out of sync for longer then 1 hour !!!" @@ -283,6 +270,16 @@ do echo "sync change detected" if [ ${lastSyncState} -eq 1 ] && [ ${lndSynced} -eq 0 ]; then echo "--> LND SYNC LOST" + + if [ "${backupTorrentSeeding}" == "on" ]; then + #echo "Backup Torrent Seeding is ON - check if still running" + source <(sudo -u admin /home/admin/50torrentHDD.sh status) + if [ "${baseSeeding}" == "1" ] || [ "${updateSeeding}" == "1" ]; then + echo "---> STOPPING Backup Torrent Seeding" + sudo -u admin /home/admin/50torrentHDD.sh stop + fi + fi + else if [ ${syncedSince} -eq 0 ]; then echo "--> LND SYNC GAINED" From 7cb8ac1c667bbbe9e9f950edb57b51c80bc05728 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 21:48:17 +0100 Subject: [PATCH 039/162] fix typo scan screen --- home.admin/80scanLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index ba03905..75e4bc1 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -71,7 +71,7 @@ if [ ${online} -eq 0 ]; then infoStr=$(echo " Waiting INTERNET CONNECTION\n RaspiBlitz cannot ping 1.0.0.1\n Local IP is ${localip}\n Please check cables and router.") elif [ ${isInitialChainSync} -gt 0 ]; then heigh=7 - infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress} %\n Please wait - this can take some time.\n ssh admin@${localip}\n Password A" + infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress} \n Please wait - this can take some time.\n ssh admin@${localip}\n Password A" if [ "$USER" = "admin" ]; then heigh=6 width=53 From db0084d5470cb105769cf3aaa60554fcbe865c33 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 22:21:27 +0100 Subject: [PATCH 040/162] open channel info --- home.admin/BBcashoutWallet.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index f90bc2e..6e2948c 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -26,15 +26,23 @@ if [ ${#openChannels} -eq 0 ]; then 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 + whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno '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' 10 56 + if [ $? -eq 1 ]; then + exit 1 + fi echo "please wait ..." + exit 1 fi # check if money is waiting to get confirmed unconfirmed=$(lncli --chain=${network} --network=${chain}net 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 + if [ $? -eq 1 ]; then + exit 1 + fi echo "please wait ..." + exit 1 fi # get available amount in on-chain wallet From d153f05855df26e41fc824a32907cb03b7841748 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 22:32:47 +0100 Subject: [PATCH 041/162] simplify cashout script --- home.admin/BBcashoutWallet.sh | 40 +++++++++++------------------------ 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index 6e2948c..fad7109 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -30,34 +30,24 @@ if [ ${openChannels} -gt 0 ]; then if [ $? -eq 1 ]; then exit 1 fi - echo "please wait ..." + echo "..." exit 1 fi # check if money is waiting to get confirmed unconfirmed=$(lncli --chain=${network} --network=${chain}net 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 + whiptail--title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58 if [ $? -eq 1 ]; then exit 1 fi - echo "please wait ..." - exit 1 -fi - -# get available amount in on-chain wallet -maxAmount=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4) -if [ ${maxAmount} -eq 0 ]; then - dialog --title 'Info' --msgbox "You have 0 moveable funds available.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58 + echo "..." exit 1 fi # let user enter the address l1="Enter on-chain address to send confirmed funds to:" -#l2="You will send: ${maxAmount} sat" -#l3="Maximal fee: 20000 sat (wil be subtracted)" -dialog --title "Where to send funds?" \ ---inputbox "\n$l1\n" 9 75 2>$_temp +dialog --title "Where to send funds?" --inputbox "\n$l1\n" 9 75 2>$_temp if test $? -eq 0 then echo "ok pressed" @@ -74,7 +64,7 @@ fi clear echo "******************************" -echo "Send on-chain Funds" +echo "Sweep all possible Funds" echo "******************************" # execute command @@ -82,22 +72,16 @@ command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --a echo "$command" result=$($command 2>$_error) error=`cat ${_error}` - -if [ ${#result} -eq 0 ]; then - # fail - retry on 'insufficient funds available to construct transaction' - echo "FAIL: $error" - tryAgain=$(echo "${error}" | grep -c 'insufficient funds available to construct transaction') - if [ ${tryAgain} -eq 0 ]; then +echo "" +if [ ${#error} -eq 0 ]; then + echo "FAIL: $error" echo "" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "FINAL FAIL --> Was not able to send transaction (see error above)" + echo "FAIL --> Was not able to send transaction (see error above)" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - else - # success - echo "$result" +else + echo "Result: $result" echo "" echo "********************************************************************" - echo "OK --> to address ${address}" - echo "********************************************************************" - fi +fi echo "" From c1ab921c8e4233b1fac56ef471e408150186765d Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 22:37:03 +0100 Subject: [PATCH 042/162] main menu info --- home.admin/00mainMenu.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index ba40151..e7b25c4 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -56,14 +56,14 @@ if [ "${state}" = "recovered" ]; then echo "System recovered - needs final user settings" ./20recoverDialog.sh exit 1 -fi +fi # signal that a reindex was triggered if [ "${state}" = "reindex" ]; then echo "Re-Index in progress ... start monitoring:" /home/admin/config.scripts/network.reindex.sh exit 1 -fi +fi # singal that torrent is in re-download if [ "${state}" = "retorrent" ]; then @@ -315,6 +315,7 @@ else waitUntilChainNetworkIsReady # MAIN MENU AFTER SETUP + source ${configFile} plus="" if [ "${runBehindTor}" = "on" ]; then From 042e26bd36b6a840c1a5b4d59e0fe9838c285502 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 22:40:37 +0100 Subject: [PATCH 043/162] remive debug exits --- home.admin/BBcashoutWallet.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index fad7109..ef0715e 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -31,7 +31,6 @@ if [ ${openChannels} -gt 0 ]; then exit 1 fi echo "..." - exit 1 fi # check if money is waiting to get confirmed @@ -42,7 +41,6 @@ if [ ${unconfirmed} -gt 0 ]; then exit 1 fi echo "..." - exit 1 fi # let user enter the address From 5d5159c75abdf5b8782d6e465fcb40878e44c65f Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 22:46:04 +0100 Subject: [PATCH 044/162] Fix Cashout Result --- home.admin/BBcashoutWallet.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index ef0715e..bed3f47 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -66,12 +66,12 @@ echo "Sweep all possible Funds" echo "******************************" # execute command -command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --addr=${address} --conf_target=3" +command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --addr=${address} --conf_target=6" echo "$command" result=$($command 2>$_error) error=`cat ${_error}` echo "" -if [ ${#error} -eq 0 ]; then +if [ ${#error} -gt 0 ]; then echo "FAIL: $error" echo "" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" From 436dfc7b40ac09a33ec642d4c61e988dd0e7a5ca Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 23:53:29 +0100 Subject: [PATCH 045/162] press enter moved --- home.admin/00mainMenu.sh | 2 -- home.admin/BBcashoutWallet.sh | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index e7b25c4..21cb827 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -449,8 +449,6 @@ case $CHOICE in ;; CASHOUT) ./BBcashoutWallet.sh - echo "Press ENTER to return to main menu." - read key ./00mainMenu.sh ;; CHANNEL) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index bed3f47..1f85902 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -22,6 +22,8 @@ if [ ${#openChannels} -eq 0 ]; then echo "Still starting up, is locked or is not running?" echo "Try later, try reboot or check ./XXdebugLogs.sh" echo "************************************************" + echo "Press ENTER to return to main menu." + read key exit 1 fi @@ -57,6 +59,8 @@ address=$(cat $_temp | xargs) shred $_temp if [ ${#address} -eq 0 ]; then echo "FAIL - not a valid address (${address})" + echo "Press ENTER to return to main menu." + read key exit 1 fi @@ -83,3 +87,5 @@ else echo "********************************************************************" fi echo "" +echo "Press ENTER to return to main menu." +read key \ No newline at end of file From 6e820e9edc0514aedff5ea473832ea818ac1a98c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 23:57:09 +0100 Subject: [PATCH 046/162] fix detect unconfirmed balance --- home.admin/BBcashoutWallet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index 1f85902..f4865a9 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -38,7 +38,7 @@ fi # check if money is waiting to get confirmed unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4) if [ ${unconfirmed} -gt 0 ]; then - whiptail--title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58 + whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58 if [ $? -eq 1 ]; then exit 1 fi From 7551dfe0e60231f17ab2a0376740af0b31d665f7 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 15 Apr 2019 23:58:51 +0100 Subject: [PATCH 047/162] fix dialog --- home.admin/BBcashoutWallet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index f4865a9..27986c2 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -38,7 +38,7 @@ fi # check if money is waiting to get confirmed unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4) if [ ${unconfirmed} -gt 0 ]; then - whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58 + whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58 if [ $? -eq 1 ]; then exit 1 fi From f54452301af9bf488480b6fb1d013afb9bc0b983 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 00:00:26 +0100 Subject: [PATCH 048/162] fix text --- home.admin/BBcashoutWallet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index 27986c2..aa5b60e 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -38,7 +38,7 @@ fi # check if money is waiting to get confirmed unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4) if [ ${unconfirmed} -gt 0 ]; then - whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58 + whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for (some of) your funds.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58 if [ $? -eq 1 ]; then exit 1 fi From 46aaeb3f12ff534914e25f0ac7174e6ebbda849e Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 01:50:41 +0100 Subject: [PATCH 049/162] #437 internet.sshpubkey.sh --- .../config.scripts/internet.sshpubkey.sh | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 home.admin/config.scripts/internet.sshpubkey.sh diff --git a/home.admin/config.scripts/internet.sshpubkey.sh b/home.admin/config.scripts/internet.sshpubkey.sh new file mode 100755 index 0000000..8622030 --- /dev/null +++ b/home.admin/config.scripts/internet.sshpubkey.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "# config script to init/show/transfer ssh pub keys." + echo "# To init and return pubkey as data:" + echo "# internet.sshpubkey.sh get" + echo "# To init and transfer ssh-pub to a authorizedkey of remote server:" + echo "# internet.sshpubkey.sh transfer [REMOTEUSER]@[REMOTESERVER]" + echo "err='just informational output'" + exit 1 +fi + +# 1. parameter MODE +MODE="$1" + +# root as default user +# its used for all ssh tunnel/back action +USER="root" + +# make sure the ssh keys for that user are initialized +sshKeysExist=$(sudo -u ${USER} ls ~/.ssh/id_rsa.pub | grep -c 'id_rsa.pub') +if [ ${sshKeysExist} -eq 0 ]; then + echo "# generation SSH keys for user ${USER}" + sudo -u ${USER} mkdir ~/.ssh + sudo sh -c 'yes y | sudo -u ${USER} ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""' +fi + +if [ "${MODE}" == "get" ]; then + + # get ssh pub key and print + sshPubKey=$(sudo -u ${USER} cat ~/.ssh/id_rsa.pub) + echo "user='${USER}'" + echo "sshPubKey='${sshPubKey}'" + +elif [ "${MODE}" == "transfer" ]; then + + sudo -u ${USER} ssh-copy-id $2 + +else + echo "err='paremeter not known - run with -help'" +fi + + From 3e217158c6a1652aefe2132bc224bf881a3b1d4e Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 02:00:58 +0100 Subject: [PATCH 050/162] auto yes --- home.admin/config.scripts/internet.sshpubkey.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/internet.sshpubkey.sh b/home.admin/config.scripts/internet.sshpubkey.sh index 8622030..7a99a73 100755 --- a/home.admin/config.scripts/internet.sshpubkey.sh +++ b/home.admin/config.scripts/internet.sshpubkey.sh @@ -35,7 +35,7 @@ if [ "${MODE}" == "get" ]; then elif [ "${MODE}" == "transfer" ]; then - sudo -u ${USER} ssh-copy-id $2 + sudo sh -c 'yes yes | sudo -u ${USER} ssh-copy-id $2' else echo "err='paremeter not known - run with -help'" From 530a6a96a6ecf1c37176afec02da00243229bf28 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 02:04:57 +0100 Subject: [PATCH 051/162] try fix --- home.admin/config.scripts/internet.sshpubkey.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/home.admin/config.scripts/internet.sshpubkey.sh b/home.admin/config.scripts/internet.sshpubkey.sh index 7a99a73..887ae11 100755 --- a/home.admin/config.scripts/internet.sshpubkey.sh +++ b/home.admin/config.scripts/internet.sshpubkey.sh @@ -16,26 +16,25 @@ MODE="$1" # root as default user # its used for all ssh tunnel/back action -USER="root" # make sure the ssh keys for that user are initialized -sshKeysExist=$(sudo -u ${USER} ls ~/.ssh/id_rsa.pub | grep -c 'id_rsa.pub') +sshKeysExist=$(sudo ls /root/.ssh/id_rsa.pub | grep -c 'id_rsa.pub') if [ ${sshKeysExist} -eq 0 ]; then - echo "# generation SSH keys for user ${USER}" - sudo -u ${USER} mkdir ~/.ssh - sudo sh -c 'yes y | sudo -u ${USER} ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""' + echo "# generation SSH keys for user root" + sudo mkdir /root/.ssh 2>/dev/null + sudo sh -c 'yes y | sudo ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""' fi if [ "${MODE}" == "get" ]; then # get ssh pub key and print - sshPubKey=$(sudo -u ${USER} cat ~/.ssh/id_rsa.pub) - echo "user='${USER}'" + sshPubKey=$(sudo cat /root/.ssh/id_rsa.pub) + echo "user='root'" echo "sshPubKey='${sshPubKey}'" elif [ "${MODE}" == "transfer" ]; then - sudo sh -c 'yes yes | sudo -u ${USER} ssh-copy-id $2' + sudo sh -c 'yes yes | sudo ssh-copy-id $2' else echo "err='paremeter not known - run with -help'" From 4229644b460dc2c8d7cd74664579416caea2ee6e Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 02:10:58 +0100 Subject: [PATCH 052/162] UserKnownHostsFile=/dev/null --- home.admin/_background.sh | 4 +++- home.admin/config.scripts/internet.sshpubkey.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 6ae2763..3945085 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -181,7 +181,9 @@ do # https://www.linode.com/docs/security/authentication/use-public-key-authentication-with-ssh/ if [ ${#scpBackupTarget} -gt 0 ]; then echo "--> Offsite-Backup SCP Server" - sudo scp /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup + # its ok to ignore known host, because data is encrypted (worst case of MiM would be: no offsite channel backup) + # but its more likely that whithout ignoriing known host, script might not run thru and that way: no offsite channel backup + sudo scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup result=$? if [ ${result} -eq 0 ]; then echo "OK - SCP Backup exited with 0" diff --git a/home.admin/config.scripts/internet.sshpubkey.sh b/home.admin/config.scripts/internet.sshpubkey.sh index 887ae11..98553cb 100755 --- a/home.admin/config.scripts/internet.sshpubkey.sh +++ b/home.admin/config.scripts/internet.sshpubkey.sh @@ -34,7 +34,7 @@ if [ "${MODE}" == "get" ]; then elif [ "${MODE}" == "transfer" ]; then - sudo sh -c 'yes yes | sudo ssh-copy-id $2' + sudo ssh-copy-id $2 else echo "err='paremeter not known - run with -help'" From e29d1169eb493e69ed6e89f135b59fe515e64050 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 02:34:38 +0100 Subject: [PATCH 053/162] recover menu --- home.admin/70initLND.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 5d6953a..13350dc 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -200,19 +200,39 @@ if [ ${walletExists} -eq 0 ]; then else + OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \ + SEED+SCB "Seed & channel.backup file (OK)" \ + ONLYSEED "Only Seed Word List (FALLBACK)") + CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "What Recover Data do you have=" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + echo "choice($CHOICE)" + + if [ "${CHOICE}" == "ONLYSEED" ]; then + echo "TODO: ONLYSEED" + exit 1 + elif [ "${CHOICE}" == "SEED+SCB" ]; then + echo "TODO: SEED+SCB" + exit 1 + elif [ "${CHOICE}" == "LNDRESCUE" ]; then + sudo /home/admin/config.scripts/lnd.rescue.sh restore + else + echo "CANCEL" + /home/admin/70initLND.sh + exit 1 + fi + # TODO: IMPLEMENT # - Recover with Seed Word List # --> (ask if seed word list was password D protected) - # - Recover with Seed Word List & Channel Backup Snapshot File + # - Recover with Seed Word List & channel.backup file # --> (ask if seed word list was password D protected) # - Restore LND backup made with Rescue-Script (tar.gz-file) # --> run retsore script # FALLBACK TO lncli create FOR NOW - dialog --title "OK" --msgbox "\nI will start 'lncli create' for you ..." 7 44 - sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create - /home/admin/70initLND.sh - exit 1 + #dialog --title "OK" --msgbox "\nI will start 'lncli create' for you ..." 7 44 + #sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create + #/home/admin/70initLND.sh + fi From c0dd8fad2ea2b684c644fdd13043f07ce08a5884 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 02:57:18 +0100 Subject: [PATCH 054/162] restore LND backup --- home.admin/70initLND.sh | 8 ++++++++ home.admin/config.scripts/lnd.rescue.sh | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 13350dc..f02ece8 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -209,11 +209,19 @@ if [ ${walletExists} -eq 0 ]; then if [ "${CHOICE}" == "ONLYSEED" ]; then echo "TODO: ONLYSEED" exit 1 + elif [ "${CHOICE}" == "SEED+SCB" ]; then echo "TODO: SEED+SCB" exit 1 + elif [ "${CHOICE}" == "LNDRESCUE" ]; then sudo /home/admin/config.scripts/lnd.rescue.sh restore + echo "" + echo "PRESS ENTER to continue." + read key + /home/admin/70initLND.sh + exit 1 + else echo "CANCEL" /home/admin/70initLND.sh diff --git a/home.admin/config.scripts/lnd.rescue.sh b/home.admin/config.scripts/lnd.rescue.sh index a97334d..3edbdc1 100755 --- a/home.admin/config.scripts/lnd.rescue.sh +++ b/home.admin/config.scripts/lnd.rescue.sh @@ -66,9 +66,10 @@ elif [ ${mode} = "restore" ]; then echo "**************************" echo "* UPLOAD THE BACKUP FILE *" echo "**************************" - echo echo "If you have a lnd-rescue backup file on your laptop you can now" - echo "upload it and restore the your old LND state." + echo "upload it and restore the your latest LND state." + echo + echo "CAUTION: Dont restore old LND states - risk of loosing funds!" echo echo "To make upload open a new terminal on your laptop," echo "change into the directory where your lnd-rescue file is and" @@ -76,7 +77,6 @@ elif [ ${mode} = "restore" ]; then echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/" echo "" echo "Use password A to authenticate file transfere." - echo echo "PRESS ENTER when upload is done. Use CTRL-C to abort." fi if [ ${countZips} -gt 1 ]; then @@ -143,7 +143,7 @@ elif [ ${mode} = "restore" ]; then echo echo "DONE - please check if LND starts up correctly with restored state and funds." - echo "Keep in mind that some channels got forced closed by channel partners in the meanwhile." + echo "Keep in mind that some channels maybe forced closed in the meanwhile." echo else From 8ed6cec64bec3a2dcce583eda345530ac9d35272 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 03:06:58 +0100 Subject: [PATCH 055/162] small setup fixes --- home.admin/70initLND.sh | 4 ++-- home.admin/95finalSetup.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index f02ece8..8a699f4 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -203,13 +203,13 @@ if [ ${walletExists} -eq 0 ]; then OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \ SEED+SCB "Seed & channel.backup file (OK)" \ ONLYSEED "Only Seed Word List (FALLBACK)") - CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "What Recover Data do you have=" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) echo "choice($CHOICE)" if [ "${CHOICE}" == "ONLYSEED" ]; then echo "TODO: ONLYSEED" exit 1 - + elif [ "${CHOICE}" == "SEED+SCB" ]; then echo "TODO: SEED+SCB" exit 1 diff --git a/home.admin/95finalSetup.sh b/home.admin/95finalSetup.sh index a9dca34..31db77a 100755 --- a/home.admin/95finalSetup.sh +++ b/home.admin/95finalSetup.sh @@ -1,12 +1,12 @@ #!/bin/bash echo "" -# set raspiblitz config file -configFile="/mnt/hdd/raspiblitz.conf" - # load setup config source /home/admin/raspiblitz.info +# in case the config already exists +source /mnt/hdd/raspiblitz.conf 2>/dev/null + # load version source /home/admin/_version.info From a3f9687296162701bafbf42e912b04efcf2d04b1 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 03:50:38 +0100 Subject: [PATCH 056/162] input seed words --- home.admin/70initLND.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 8a699f4..f694ff2 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -206,6 +206,35 @@ if [ ${walletExists} -eq 0 ]; then CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) echo "choice($CHOICE)" + if [ "${CHOICE}" == "ONLYSEED" ] || [ "${CHOICE}" == "SEED+SCB" ]; then + # enter SEED words + while [ ${#result} -eq 0 ] + do + + # dialog to enter + dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>$_temp + wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) + shred $_temp + echo "processing ..." + + # remove spaces + wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') + + # string to array + IFS=',' read -r -a seedArray <<< "$wordstring" + + # check array + if [ ${#seedArray[@]} -eq 24 ]; then + echo "OK - 24 words" + exit 1 + else + echo "wrong number of words" + exit 1 + fi + sleep 3 + done + fi + if [ "${CHOICE}" == "ONLYSEED" ]; then echo "TODO: ONLYSEED" exit 1 From d5d5ce249dff49ca06473dc64071767c30e4e420 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 03:56:50 +0100 Subject: [PATCH 057/162] fix while loop --- home.admin/70initLND.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index f694ff2..428dc68 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -208,7 +208,8 @@ if [ ${walletExists} -eq 0 ]; then if [ "${CHOICE}" == "ONLYSEED" ] || [ "${CHOICE}" == "SEED+SCB" ]; then # enter SEED words - while [ ${#result} -eq 0 ] + wordstring="" + while [ ${#wordstring} -eq 0 ] do # dialog to enter @@ -229,6 +230,7 @@ if [ ${walletExists} -eq 0 ]; then exit 1 else echo "wrong number of words" + wordstring="" exit 1 fi sleep 3 From 35d74be7c8ddd35b45a8f6a12bc2655f9186f93c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 03:57:53 +0100 Subject: [PATCH 058/162] set temp file --- home.admin/70initLND.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 428dc68..a0008b1 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -213,6 +213,7 @@ if [ ${walletExists} -eq 0 ]; then do # dialog to enter + $_temp="/home/admin/.seed.tmp" dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>$_temp wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) shred $_temp From 09e17f68d61df03249ae5d373dc15c5e80fc51ec Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 03:59:45 +0100 Subject: [PATCH 059/162] seed result --- home.admin/70initLND.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index a0008b1..584f313 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -213,10 +213,10 @@ if [ ${walletExists} -eq 0 ]; then do # dialog to enter - $_temp="/home/admin/.seed.tmp" - dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>$_temp - wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) - shred $_temp + #$_temp="/home/admin/.seed.tmp" + wordstring=$(dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78) + #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) + #shred $_temp echo "processing ..." # remove spaces From 9bf2490256f22f8695f2886e552fcb36b6e29f9b Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:06:42 +0100 Subject: [PATCH 060/162] remove while --- home.admin/70initLND.sh | 51 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 584f313..3640f89 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -207,35 +207,30 @@ if [ ${walletExists} -eq 0 ]; then echo "choice($CHOICE)" if [ "${CHOICE}" == "ONLYSEED" ] || [ "${CHOICE}" == "SEED+SCB" ]; then - # enter SEED words - wordstring="" - while [ ${#wordstring} -eq 0 ] - do - - # dialog to enter - #$_temp="/home/admin/.seed.tmp" - wordstring=$(dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78) - #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) - #shred $_temp - echo "processing ..." - - # remove spaces - wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') - - # string to array - IFS=',' read -r -a seedArray <<< "$wordstring" + echo "ENTER SEED" + # dialog to enter + #$_temp="/home/admin/.seed.tmp" + wordstring=$(whiptail --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78) + #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) + #shred $_temp + echo "processing ..." + + # remove spaces + wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') + + # string to array + IFS=',' read -r -a seedArray <<< "$wordstring" - # check array - if [ ${#seedArray[@]} -eq 24 ]; then - echo "OK - 24 words" - exit 1 - else - echo "wrong number of words" - wordstring="" - exit 1 - fi - sleep 3 - done + # check array + if [ ${#seedArray[@]} -eq 24 ]; then + echo "OK - 24 words" + exit 1 + else + echo "wrong number of words" + wordstring="" + exit 1 + fi + fi if [ "${CHOICE}" == "ONLYSEED" ]; then From 4c5263bccb8b680b7c2d2d5b07765773d5f9dc96 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:11:05 +0100 Subject: [PATCH 061/162] test --- home.admin/70initLND.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 3640f89..2c9127b 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -201,35 +201,36 @@ if [ ${walletExists} -eq 0 ]; then else OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \ - SEED+SCB "Seed & channel.backup file (OK)" \ + SEED_SCB "Seed & channel.backup file (OK)" \ ONLYSEED "Only Seed Word List (FALLBACK)") CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) echo "choice($CHOICE)" - if [ "${CHOICE}" == "ONLYSEED" ] || [ "${CHOICE}" == "SEED+SCB" ]; then + if [ "${CHOICE}" == "SEED_SCB" ]; then + echo "ENTER SEED" # dialog to enter #$_temp="/home/admin/.seed.tmp" - wordstring=$(whiptail --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78) + dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) #shred $_temp - echo "processing ..." + #echo "processing ..." # remove spaces - wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') + #wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') # string to array - IFS=',' read -r -a seedArray <<< "$wordstring" + #IFS=',' read -r -a seedArray <<< "$wordstring" # check array - if [ ${#seedArray[@]} -eq 24 ]; then - echo "OK - 24 words" - exit 1 - else - echo "wrong number of words" - wordstring="" - exit 1 - fi + #if [ ${#seedArray[@]} -eq 24 ]; then + # echo "OK - 24 words" + # exit 1 + #else + # echo "wrong number of words" + # wordstring="" + # exit 1 + #fi fi @@ -237,7 +238,7 @@ if [ ${walletExists} -eq 0 ]; then echo "TODO: ONLYSEED" exit 1 - elif [ "${CHOICE}" == "SEED+SCB" ]; then + elif [ "${CHOICE}" == "SEED_SCB" ]; then echo "TODO: SEED+SCB" exit 1 @@ -268,7 +269,6 @@ if [ ${walletExists} -eq 0 ]; then #sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create #/home/admin/70initLND.sh - fi else From 817add4965d49c3481de52979a9a77c5f3640375 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:12:32 +0100 Subject: [PATCH 062/162] wordstring --- home.admin/70initLND.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 2c9127b..df84574 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -208,29 +208,28 @@ if [ ${walletExists} -eq 0 ]; then if [ "${CHOICE}" == "SEED_SCB" ]; then - echo "ENTER SEED" # dialog to enter #$_temp="/home/admin/.seed.tmp" - dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 + wordstring=$(dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78) #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) #shred $_temp #echo "processing ..." # remove spaces - #wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') + wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') # string to array - #IFS=',' read -r -a seedArray <<< "$wordstring" + IFS=',' read -r -a seedArray <<< "$wordstring" # check array - #if [ ${#seedArray[@]} -eq 24 ]; then - # echo "OK - 24 words" - # exit 1 - #else - # echo "wrong number of words" - # wordstring="" - # exit 1 - #fi + if [ ${#seedArray[@]} -eq 24 ]; then + echo "OK - 24 words" + exit 1 + else + echo "wrong number of words" + wordstring="" + exit 1 + fi fi From 55d051b5d2f060a809493ae8d0c1b2dfde473140 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:13:19 +0100 Subject: [PATCH 063/162] test --- home.admin/70initLND.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index df84574..a2e87fc 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -216,20 +216,20 @@ if [ ${walletExists} -eq 0 ]; then #echo "processing ..." # remove spaces - wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') + #wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') # string to array - IFS=',' read -r -a seedArray <<< "$wordstring" + #IFS=',' read -r -a seedArray <<< "$wordstring" # check array - if [ ${#seedArray[@]} -eq 24 ]; then - echo "OK - 24 words" - exit 1 - else - echo "wrong number of words" - wordstring="" - exit 1 - fi + #if [ ${#seedArray[@]} -eq 24 ]; then + # echo "OK - 24 words" + # exit 1 + #else + # echo "wrong number of words" + # wordstring="" + # exit 1 + #fi fi From cf6b603cd4dd557a92cd325e9ab5996bc8039361 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:13:58 +0100 Subject: [PATCH 064/162] test --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index a2e87fc..a5f35b2 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -210,7 +210,7 @@ if [ ${walletExists} -eq 0 ]; then # dialog to enter #$_temp="/home/admin/.seed.tmp" - wordstring=$(dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78) + dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) #shred $_temp #echo "processing ..." From 2a53f95e793caaa99d0692b7024179555c265125 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:15:18 +0100 Subject: [PATCH 065/162] wordstring --- home.admin/70initLND.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index a5f35b2..2645f70 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -209,11 +209,11 @@ if [ ${walletExists} -eq 0 ]; then if [ "${CHOICE}" == "SEED_SCB" ]; then # dialog to enter - #$_temp="/home/admin/.seed.tmp" - dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 - #wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) - #shred $_temp - #echo "processing ..." + $_temp="/home/admin/.seed.tmp" + dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>$_temp + wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) + shred $_temp + echo "processing ... ${wordstring}" # remove spaces #wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') From d1a067c5cad7f23bc2ec1edc2638d63e45ec60f0 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:16:44 +0100 Subject: [PATCH 066/162] temp file --- home.admin/70initLND.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 2645f70..478f082 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -209,10 +209,9 @@ if [ ${walletExists} -eq 0 ]; then if [ "${CHOICE}" == "SEED_SCB" ]; then # dialog to enter - $_temp="/home/admin/.seed.tmp" - dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>$_temp - wordstring=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' ) - shred $_temp + dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp + wordstring=$( cat /home/admin/.seed.tmp | tr -dc '[:alnum:]-.' | tr -d ' ' ) + shred /home/admin/.seed.tmp echo "processing ... ${wordstring}" # remove spaces From e84910ddf9a10cb1cfa1d2644a5944a815f7985f Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:17:27 +0100 Subject: [PATCH 067/162] split words --- home.admin/70initLND.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 478f082..a31f27f 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -215,20 +215,20 @@ if [ ${walletExists} -eq 0 ]; then echo "processing ... ${wordstring}" # remove spaces - #wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') + wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') # string to array - #IFS=',' read -r -a seedArray <<< "$wordstring" + IFS=',' read -r -a seedArray <<< "$wordstring" # check array - #if [ ${#seedArray[@]} -eq 24 ]; then - # echo "OK - 24 words" - # exit 1 - #else - # echo "wrong number of words" - # wordstring="" - # exit 1 - #fi + if [ ${#seedArray[@]} -eq 24 ]; then + echo "OK - 24 words" + exit 1 + else + echo "wrong number of words" + wordstring="" + exit 1 + fi fi From 85d5aacc24fe462b19737627b15301dadc0ea0f7 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:19:07 +0100 Subject: [PATCH 068/162] split words --- home.admin/70initLND.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index a31f27f..66c9ccf 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -206,17 +206,14 @@ if [ ${walletExists} -eq 0 ]; then CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) echo "choice($CHOICE)" - if [ "${CHOICE}" == "SEED_SCB" ]; then + if [ "${CHOICE}" == "SEED_SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then # dialog to enter dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp - wordstring=$( cat /home/admin/.seed.tmp | tr -dc '[:alnum:]-.' | tr -d ' ' ) + wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9 ]//g' ) shred /home/admin/.seed.tmp echo "processing ... ${wordstring}" - # remove spaces - wordstring=$(echo "${wordstring}" | sed 's/[^a-zA-Z0-9 ]//g') - # string to array IFS=',' read -r -a seedArray <<< "$wordstring" From e1cdecbb8ef6f0f3044cffec9a179bcb628ef9c4 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:21:11 +0100 Subject: [PATCH 069/162] debug count --- home.admin/70initLND.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 66c9ccf..9fca09e 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -218,6 +218,7 @@ if [ ${walletExists} -eq 0 ]; then IFS=',' read -r -a seedArray <<< "$wordstring" # check array + echo "numWords(${#seedArray[@]})" if [ ${#seedArray[@]} -eq 24 ]; then echo "OK - 24 words" exit 1 From 6dc9b0fc54aa14a797da7ec011b9cfe54836f6e8 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 04:22:13 +0100 Subject: [PATCH 070/162] replacement --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 9fca09e..46f5bfd 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -210,7 +210,7 @@ if [ ${walletExists} -eq 0 ]; then # dialog to enter dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp - wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9 ]//g' ) + wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9,]//g' ) shred /home/admin/.seed.tmp echo "processing ... ${wordstring}" From 7f97c8ee253f585563278065b64b311f52353d49 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 12:39:29 +0100 Subject: [PATCH 071/162] check word lidt numers --- home.admin/70initLND.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 46f5bfd..a61c352 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -201,12 +201,11 @@ if [ ${walletExists} -eq 0 ]; then else OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \ - SEED_SCB "Seed & channel.backup file (OK)" \ + SEED+SCB "Seed & channel.backup file (OK)" \ ONLYSEED "Only Seed Word List (FALLBACK)") CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) - echo "choice($CHOICE)" - if [ "${CHOICE}" == "SEED_SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then + if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then # dialog to enter dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp @@ -214,28 +213,36 @@ if [ ${walletExists} -eq 0 ]; then shred /home/admin/.seed.tmp echo "processing ... ${wordstring}" - # string to array + # check correct number of words IFS=',' read -r -a seedArray <<< "$wordstring" - - # check array - echo "numWords(${#seedArray[@]})" if [ ${#seedArray[@]} -eq 24 ]; then echo "OK - 24 words" - exit 1 else - echo "wrong number of words" - wordstring="" + whiptail --title " WARNING " --msgbox " +The word list has ${#seedArray[@]} words. But it must be 24. +Please check your list and try again. + +Best is to write words in external editor +and then copy and paste them into dialog. + +The Word list should look like this: +wordone,wordtweo,wordthree, ... + +" 16 52 exit 1 + /home/admin/70initLND.sh fi + + fi if [ "${CHOICE}" == "ONLYSEED" ]; then - echo "TODO: ONLYSEED" + echo "TODO: ONLYSEED words(${wordstring})" exit 1 - elif [ "${CHOICE}" == "SEED_SCB" ]; then - echo "TODO: SEED+SCB" + elif [ "${CHOICE}" == "SEED+SCB" ]; then + echo "TODO: SEED+SCB words(${wordstring})" exit 1 elif [ "${CHOICE}" == "LNDRESCUE" ]; then From c6c1d0966991cd8148d239150786894442b32912 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 12:46:32 +0100 Subject: [PATCH 072/162] prepare get scb file --- home.admin/70initLND.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index a61c352..699127f 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -205,6 +205,7 @@ if [ ${walletExists} -eq 0 ]; then ONLYSEED "Only Seed Word List (FALLBACK)") CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + # get seed word list if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then # dialog to enter @@ -229,12 +230,9 @@ The Word list should look like this: wordone,wordtweo,wordthree, ... " 16 52 - exit 1 /home/admin/70initLND.sh + exit 1 fi - - - fi if [ "${CHOICE}" == "ONLYSEED" ]; then @@ -243,6 +241,15 @@ wordone,wordtweo,wordthree, ... elif [ "${CHOICE}" == "SEED+SCB" ]; then echo "TODO: SEED+SCB words(${wordstring})" + + # get the channel.backup file + gotFile=0 + while [ ${gotFile} -eq 0]; + do + echo "Please upload file. Press Enter or CTRL-X to cancel:" + read key + done + exit 1 elif [ "${CHOICE}" == "LNDRESCUE" ]; then From 1949c8085c1d1ae1a504e4b1fe856f88f0ba416c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 12:47:38 +0100 Subject: [PATCH 073/162] fix while loop --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 699127f..4530314 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -244,7 +244,7 @@ wordone,wordtweo,wordthree, ... # get the channel.backup file gotFile=0 - while [ ${gotFile} -eq 0]; + while [ ${gotFile} -eq 0 ] do echo "Please upload file. Press Enter or CTRL-X to cancel:" read key From d9246bcd0bd22969e4932c47ec7f9689f27a7a58 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 12:50:13 +0100 Subject: [PATCH 074/162] test cancel loop --- home.admin/70initLND.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 4530314..f34bd90 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -206,7 +206,7 @@ if [ ${walletExists} -eq 0 ]; then CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) # get seed word list - if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then + if [ "${CHOICE}" == "!SEED+SCB" ] || [ "${CHOICE}" == "!ONLYSEED" ]; then # dialog to enter dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp @@ -246,8 +246,9 @@ wordone,wordtweo,wordthree, ... gotFile=0 while [ ${gotFile} -eq 0 ] do - echo "Please upload file. Press Enter or CTRL-X to cancel:" + echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel:" read key + echo "key(${key})" done exit 1 From 26fe1018a566a99243022a3f2cd85dba4677b9b5 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 13:22:29 +0100 Subject: [PATCH 075/162] delete old rescue backups --- home.admin/70initLND.sh | 17 +++++++++++++++++ home.admin/config.scripts/lnd.rescue.sh | 17 ++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index f34bd90..dc0490b 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -246,6 +246,23 @@ wordone,wordtweo,wordthree, ... gotFile=0 while [ ${gotFile} -eq 0 ] do + + echo "**********************************" + echo "* UPLOAD THE channel.backup FILE *" + echo "**********************************" + echo "If you have a lnd-rescue backup file on your laptop you can now" + echo "upload it and restore the your latest LND state." + echo + echo "CAUTION: Dont restore old LND states - risk of loosing funds!" + echo + echo "To make upload open a new terminal on your laptop," + echo "change into the directory where your lnd-rescue file is and" + echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" + echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/" + echo "" + echo "Use password A to authenticate file transfere." + echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel." + echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel:" read key echo "key(${key})" diff --git a/home.admin/config.scripts/lnd.rescue.sh b/home.admin/config.scripts/lnd.rescue.sh index 3edbdc1..8a6f154 100755 --- a/home.admin/config.scripts/lnd.rescue.sh +++ b/home.admin/config.scripts/lnd.rescue.sh @@ -29,6 +29,9 @@ if [ ${mode} = "backup" ]; then sudo tar -zcvf /home/admin/lnd-rescue.tar.gz /mnt/hdd/lnd sudo chown admin:admin /home/admin/lnd-rescue.tar.gz + # delete old backups + rm /home/admin/lnd-rescue-*.tar.gz + # name with md5 checksum md5checksum=$(md5sum /home/admin/lnd-rescue.tar.gz | head -n1 | cut -d " " -f1) mv /home/admin/lnd-rescue.tar.gz /home/admin/lnd-rescue-${md5checksum}.tar.gz @@ -58,6 +61,9 @@ elif [ ${mode} = "restore" ]; then echo "*** LND.RESCUE --> RESTORE" echo "" + # delete old backups + rm /home/admin/lnd-rescue-*.tar.gz + filename="" while [ ${#filename} -eq 0 ] do @@ -77,13 +83,15 @@ elif [ ${mode} = "restore" ]; then echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/" echo "" echo "Use password A to authenticate file transfere." - echo "PRESS ENTER when upload is done. Use CTRL-C to abort." + echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel." fi if [ ${countZips} -gt 1 ]; then echo "!! WARNING !!" echo "There are multiple lnd-rescue files in directory /home/admin." - echo "Make sure there is only one file to work with and start again." + echo "Make sure you upload only one tar.gz-file and start again." echo + echo "PRESS ENTER to continue." + read key exit 1 fi if [ ${countZips} -eq 1 ]; then @@ -111,9 +119,12 @@ elif [ ${mode} = "restore" ]; then echo echo "WARNING: This will delete/overwrite the LND state/funds of this RaspiBlitz." echo - echo "PRESS ENTER to start restore. Use CTRL-C to abort." + echo "PRESS ENTER to start restore. Enter x & ENTER to cancel." fi read key + if [ "${key}" == "x" ]; then + exit 1 + fi done # stop LND From 899383941da2078b4d65a4e3f9ce8d3a5a703a74 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 13:35:25 +0100 Subject: [PATCH 076/162] SCB upload --- home.admin/70initLND.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index dc0490b..ac556eb 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -243,29 +243,45 @@ wordone,wordtweo,wordthree, ... echo "TODO: SEED+SCB words(${wordstring})" # get the channel.backup file - gotFile=0 - while [ ${gotFile} -eq 0 ] + gotFile=-1 + while [ ${gotFile} -lt 1 ] do + # show info echo "**********************************" echo "* UPLOAD THE channel.backup FILE *" echo "**********************************" - echo "If you have a lnd-rescue backup file on your laptop you can now" - echo "upload it and restore the your latest LND state." echo - echo "CAUTION: Dont restore old LND states - risk of loosing funds!" + if [ ${gotFile} -eq -1 ]; then + echo "If you have the channel.backup file on your laptop or on" + echo "another server you can now upload it to the RaspiBlitz." + elif [ ${gotFile} -eq 0 ]; then + echo "NO channel.backup FOUND IN /home/admin" + echo "Please try upload again." + else + echo "OK channel.backup file found" + break + fi echo - echo "To make upload open a new terminal on your laptop," - echo "change into the directory where your lnd-rescue file is and" + echo "To make upload open a new terminal and change," + echo "into the directory where your lnd-rescue file is and" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" - echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/" + echo "scp ./channel.backup admin@${localip}:/home/admin/" echo "" echo "Use password A to authenticate file transfere." echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel." - echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel:" + # wait user interaction + echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel." read key - echo "key(${key})" + if [ "${key}" == "x" ]; then + /home/admin/70initLND.sh + exit 1 + fi + + # test upload + gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup') + done exit 1 From cd30edf9098d4da9023d6c4ba167f2fc5977263f Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 13:39:38 +0100 Subject: [PATCH 077/162] change backupfolder name --- home.admin/config.scripts/dropbox.upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/dropbox.upload.sh b/home.admin/config.scripts/dropbox.upload.sh index d33dc7e..6f2569b 100644 --- a/home.admin/config.scripts/dropbox.upload.sh +++ b/home.admin/config.scripts/dropbox.upload.sh @@ -55,7 +55,7 @@ elif [ "${MODE}" == "upload" ]; then fi DEVICE=$(echo "${hostname}" | awk '{print tolower($0)}' | sed -e 's/ /-/g') - BACKUPFOLDER=.lndbackup-$DEVICE + BACKUPFOLDER=lndbackup-$DEVICE FILENAME=$(basename "${SOURCEFILE}") sudo curl -s -X POST https://content.dropboxapi.com/2/files/upload \ From 171ab3dbcab789f62e18d345aeb73f1ce0c2c214 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 13:40:25 +0100 Subject: [PATCH 078/162] add localip --- home.admin/70initLND.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index ac556eb..55ce1b4 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -244,10 +244,13 @@ wordone,wordtweo,wordthree, ... # get the channel.backup file gotFile=-1 + localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') while [ ${gotFile} -lt 1 ] do # show info + clear + sleep 1 echo "**********************************" echo "* UPLOAD THE channel.backup FILE *" echo "**********************************" @@ -281,7 +284,7 @@ wordone,wordtweo,wordthree, ... # test upload gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup') - + done exit 1 From 4807e17e44c1e068852f2cf00e452cb52b5fc994 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 14:10:06 +0100 Subject: [PATCH 079/162] Extra Seed Password --- home.admin/70initLND.sh | 74 +++++++++++++++++---- home.admin/config.scripts/lnd.initwallet.py | 3 +- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 55ce1b4..94b13ae 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -148,6 +148,10 @@ if [ ${walletExists} -eq 0 ]; then if [ "${CHOICE}" == "NEW" ]; then +############################ +# NEW WALLET +############################ + # let user enter password c sudo shred /home/admin/.pass.tmp 2>/dev/null sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp @@ -200,11 +204,29 @@ if [ ${walletExists} -eq 0 ]; then else +############################ +# RECOVER OLD WALLET +############################ + OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \ SEED+SCB "Seed & channel.backup file (OK)" \ ONLYSEED "Only Seed Word List (FALLBACK)") CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + # show warn when only seed + if [ "${CHOICE}" == "ONLYSEED" ]; then + whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno " +Using JUST SEED WORDS will only recover your on-chain funds. +To also try to recover the open channel funds you need the +channel.backup file (since RaspiBlitz v1.2 / LND 0.6-beta) +or having a complete LND rescue-backup from your old node. + " 11 65 + if [ $? -eq 1 ]; then + /home/admin/70initLND.sh + exit 1 + fi + fi + # get seed word list if [ "${CHOICE}" == "!SEED+SCB" ] || [ "${CHOICE}" == "!ONLYSEED" ]; then @@ -233,14 +255,39 @@ wordone,wordtweo,wordthree, ... /home/admin/70initLND.sh exit 1 fi + + # ask if seed was protected by password D + passwordD="" + dialog --title "SEED PASSWORD" --yes-button "No extra Password" --no-button "Yes" --yesno " +Are your seed words protected by an extra password? + +During wallet creation LND offers to set an extra password +to protect the seed words. Most users dont set this. + " 11 65 + if [ $? -eq 1 ]; then + sudo shred /home/admin/.pass.tmp 2>/dev/null + sudo ./config.scripts/blitz.setpassword.sh x "Enter extra Password D" /home/admin/.pass.tmp + passwordD=`sudo cat /home/admin/.pass.tmp` + sudo shred /home/admin/.pass.tmp 2>/dev/null + fi + fi + # let user enter password c + sudo shred /home/admin/.pass.tmp 2>/dev/null + sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp + passwordC=`sudo cat /home/admin/.pass.tmp` + sudo shred /home/admin/.pass.tmp 2>/dev/null + if [ "${CHOICE}" == "ONLYSEED" ]; then + + # trigger wallet recovery + source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} ${passwordD}) + echo "TODO: ONLYSEED words(${wordstring})" exit 1 elif [ "${CHOICE}" == "SEED+SCB" ]; then - echo "TODO: SEED+SCB words(${wordstring})" # get the channel.backup file gotFile=-1 @@ -261,9 +308,6 @@ wordone,wordtweo,wordthree, ... elif [ ${gotFile} -eq 0 ]; then echo "NO channel.backup FOUND IN /home/admin" echo "Please try upload again." - else - echo "OK channel.backup file found" - break fi echo echo "To make upload open a new terminal and change," @@ -287,6 +331,13 @@ wordone,wordtweo,wordthree, ... done + clear + echo "OK - channel.backup file found." + + # trigger wallet recovery + source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} /home/admin/channel.backup ${passwordD}) + + echo "TODO: Implement recovery with channel backup file" exit 1 elif [ "${CHOICE}" == "LNDRESCUE" ]; then @@ -303,15 +354,7 @@ wordone,wordtweo,wordthree, ... exit 1 fi - # TODO: IMPLEMENT - # - Recover with Seed Word List - # --> (ask if seed word list was password D protected) - # - Recover with Seed Word List & channel.backup file - # --> (ask if seed word list was password D protected) - # - Restore LND backup made with Rescue-Script (tar.gz-file) - # --> run retsore script - - # FALLBACK TO lncli create FOR NOW + # FALLBACK #dialog --title "OK" --msgbox "\nI will start 'lncli create' for you ..." 7 44 #sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create #/home/admin/70initLND.sh @@ -324,7 +367,10 @@ fi dialog --pause " Waiting for LND - please wait .." 8 58 60 -###### Copy LND macaroons to admin +############################ +# Copy LND macaroons to admin +############################ + echo "" echo "*** Copy LND Macaroons to user admin ***" macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index 6e90308..9da6556 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -105,5 +105,4 @@ elif mode=="seed": elif mode=="scb": print("err='TODO: implement creating from seed/scb'") - sys.exit(1) - + sys.exit(1) \ No newline at end of file From 656f37f8b5042c4cdef9989309b04365ad732a78 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 14:11:21 +0100 Subject: [PATCH 080/162] activate seed word list again --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 94b13ae..04f737a 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -228,7 +228,7 @@ or having a complete LND rescue-backup from your old node. fi # get seed word list - if [ "${CHOICE}" == "!SEED+SCB" ] || [ "${CHOICE}" == "!ONLYSEED" ]; then + if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then # dialog to enter dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp From 0d82ab71af9e8fe2abe0d45bfe3db1c4dae77863 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 14:23:51 +0100 Subject: [PATCH 081/162] win/fail user feedback --- home.admin/70initLND.sh | 51 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 04f737a..24ccdff 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -284,8 +284,29 @@ to protect the seed words. Most users dont set this. # trigger wallet recovery source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} ${passwordD}) - echo "TODO: ONLYSEED words(${wordstring})" - exit 1 + # on success the python script should return the seed words again + if [ ${#seedwords} -gt 1 ]; then + dialog --title " SUCCESS " --msgbox " +Looks good :) LND was able to recover the wallet. + " 7 53 + else + if [ ${#err} -eq 0 ]; then + echo + echo "FAIL!! Unkown Error - check output above for any hints and report to development." + echo "PRESS ENTER to try again." + read key + /home/admin/70initLND.sh + exit 1 + else + whiptail --title " FAIL " --msgbox " +Something went wrong - see info below: +${err} +${errMore} + " 13 72 + /home/admin/70initLND.sh + exit 1 + fi + fi elif [ "${CHOICE}" == "SEED+SCB" ]; then @@ -337,8 +358,30 @@ to protect the seed words. Most users dont set this. # trigger wallet recovery source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} /home/admin/channel.backup ${passwordD}) - echo "TODO: Implement recovery with channel backup file" - exit 1 + # WIN/FAIL User feedback + # on success the python script should return the seed words again + if [ ${#seedwords} -gt 1 ]; then + dialog --title " SUCCESS " --msgbox " +Looks good :) LND was able to recover the wallet. + " 7 53 + else + if [ ${#err} -eq 0 ]; then + echo + echo "FAIL!! Unkown Error - check output above for any hints and report to development." + echo "PRESS ENTER to try again." + read key + /home/admin/70initLND.sh + exit 1 + else + whiptail --title " FAIL " --msgbox " +Something went wrong - see info below: +${err} +${errMore} + " 13 72 + /home/admin/70initLND.sh + exit 1 + fi + fi elif [ "${CHOICE}" == "LNDRESCUE" ]; then sudo /home/admin/config.scripts/lnd.rescue.sh restore From d0c683a26bf111a6c5e47e8634edfd68533ed075 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 14:29:44 +0100 Subject: [PATCH 082/162] typo --- home.admin/70initLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 24ccdff..5174fb6 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -262,7 +262,7 @@ wordone,wordtweo,wordthree, ... Are your seed words protected by an extra password? During wallet creation LND offers to set an extra password -to protect the seed words. Most users dont set this. +to protect the seed words. Most users did not set this. " 11 65 if [ $? -eq 1 ]; then sudo shred /home/admin/.pass.tmp 2>/dev/null From d81115a518528b2bc47ac58e84eb760c48828951 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:10:15 +0100 Subject: [PATCH 083/162] change order of user dialogs --- home.admin/70initLND.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 5174fb6..93141a3 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -227,6 +227,12 @@ or having a complete LND rescue-backup from your old node. fi fi + # let user enter password c + sudo shred /home/admin/.pass.tmp 2>/dev/null + sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp + passwordC=`sudo cat /home/admin/.pass.tmp` + sudo shred /home/admin/.pass.tmp 2>/dev/null + # get seed word list if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then @@ -273,12 +279,6 @@ to protect the seed words. Most users did not set this. fi - # let user enter password c - sudo shred /home/admin/.pass.tmp 2>/dev/null - sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp - passwordC=`sudo cat /home/admin/.pass.tmp` - sudo shred /home/admin/.pass.tmp 2>/dev/null - if [ "${CHOICE}" == "ONLYSEED" ]; then # trigger wallet recovery From d5eea11afb562bcb88cb6144a3afdf19933e5ab0 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:10:25 +0100 Subject: [PATCH 084/162] recover by seed --- home.admin/config.scripts/lnd.initwallet.py | 45 ++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index 9da6556..dce3515 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -99,8 +99,49 @@ if mode=="new": elif mode=="seed": - print("err='TODO: implement creating from seed'") - sys.exit(1) + if len(sys.argv)>2: + walletpassword=sys.argv[2] + if len(walletpassword)<8: + print("err='wallet password is too short'") + sys.exit(1) + else: + print("err='not correct amount of parameter'") + sys.exit(1) + + if len(sys.argv)>3: + seedwordString=sys.argv[3] + seedwords=seedwordString.split(",") + if len(seedwords)<24: + print("err='not 24 seed words seperated by just commas'") + sys.exit(1) + else: + print("err='not correct amount of parameter'") + sys.exit(1) + + if len(sys.argv)>4: + seedpassword=sys.argv[4] + + request = ln.InitWalletRequest( + wallet_password=walletpassword, + cipher_seed_mnemonic=seedwords, + recovery_window=1000 + ) + + if len(seedpassword)>0: + request = ln.InitWalletRequest( + wallet_password=walletpassword, + cipher_seed_mnemonic=seedwords, + aezeed_passphrase=seedpassword, + recovery_window=1000 + ) + + try: + response = stub.InitWallet(request) + except: + e = sys.exc_info()[0] + print >> sys.stderr, e + print("err='Failed: RPC InitWallet'") + sys.exit(1) elif mode=="scb": From a5a762f4cf6a09cc0db53f884e1c6576018ce518 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:15:19 +0100 Subject: [PATCH 085/162] fix seed parameters --- home.admin/config.scripts/lnd.initwallet.py | 43 ++++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index dce3515..77be827 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -37,9 +37,28 @@ if mode=="new": elif mode=="seed": - print("err='TODO: implement creating from seed'") + if len(sys.argv)>2: + walletpassword=sys.argv[2] + if len(walletpassword)<8: + print("err='wallet password is too short'") + sys.exit(1) + else: + print("err='not correct amount of parameter'") sys.exit(1) + if len(sys.argv)>3: + seedwordString=sys.argv[3] + seedwords=seedwordString.split(",") + if len(seedwords)<24: + print("err='not 24 seed words seperated by just commas'") + sys.exit(1) + else: + print("err='not correct amount of parameter'") + sys.exit(1) + + if len(sys.argv)>4: + seedpassword=sys.argv[4] + elif mode=="scb": print("err='TODO: implement creating from seed/scb'") @@ -99,28 +118,6 @@ if mode=="new": elif mode=="seed": - if len(sys.argv)>2: - walletpassword=sys.argv[2] - if len(walletpassword)<8: - print("err='wallet password is too short'") - sys.exit(1) - else: - print("err='not correct amount of parameter'") - sys.exit(1) - - if len(sys.argv)>3: - seedwordString=sys.argv[3] - seedwords=seedwordString.split(",") - if len(seedwords)<24: - print("err='not 24 seed words seperated by just commas'") - sys.exit(1) - else: - print("err='not correct amount of parameter'") - sys.exit(1) - - if len(sys.argv)>4: - seedpassword=sys.argv[4] - request = ln.InitWalletRequest( wallet_password=walletpassword, cipher_seed_mnemonic=seedwords, From a6920e97206c941d176f6e3586bf72ef08f7273a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:18:55 +0100 Subject: [PATCH 086/162] try more details on error --- home.admin/config.scripts/lnd.initwallet.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index 77be827..e2135d7 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -138,6 +138,8 @@ elif mode=="seed": e = sys.exc_info()[0] print >> sys.stderr, e print("err='Failed: RPC InitWallet'") + message = e.details() + print("errMore='"+message+"'") sys.exit(1) elif mode=="scb": From 06d328c408a29a802d2ca4fcfa0cf703f8fafd99 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:21:44 +0100 Subject: [PATCH 087/162] more error details --- home.admin/config.scripts/lnd.initwallet.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index e2135d7..cd311d9 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -134,12 +134,15 @@ elif mode=="seed": try: response = stub.InitWallet(request) + except grpc.RpcError as rpc_error_call: + code = rpc_error_call.code() + details = rpc_error_call.details() + print("err='Failed: RPCError InitWallet "+code+"'") + print("errMore='"+details+"'") except: e = sys.exc_info()[0] print >> sys.stderr, e print("err='Failed: RPC InitWallet'") - message = e.details() - print("errMore='"+message+"'") sys.exit(1) elif mode=="scb": From c6085e8e022cfd1e395e27162a7f6017a76765f3 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:23:12 +0100 Subject: [PATCH 088/162] correct output --- home.admin/config.scripts/lnd.initwallet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index cd311d9..fa37295 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -137,7 +137,9 @@ elif mode=="seed": except grpc.RpcError as rpc_error_call: code = rpc_error_call.code() details = rpc_error_call.details() - print("err='Failed: RPCError InitWallet "+code+"'") + print >> sys.stderr, code + print >> sys.stderr, details + print("err='Failed: RPCError InitWallet'") print("errMore='"+details+"'") except: e = sys.exc_info()[0] From dfcde6a73e5be8f5316326681a17535181d858e2 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:27:44 +0100 Subject: [PATCH 089/162] more debug --- home.admin/config.scripts/lnd.initwallet.py | 39 +++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index fa37295..f5e2d93 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -94,14 +94,17 @@ if mode=="new": seedwords6x4=seedwords6x4+singleWord print("seedwords6x4='"+seedwords6x4+"'") - except grpc.RpcError as err: - # - wallet might already exist - print("err='grpc.RpcError'") - print >> sys.stderr, err + except grpc.RpcError as rpc_error_call: + code = rpc_error_call.code() + print >> sys.stderr, code + details = rpc_error_call.details() + print("err='RPCError GenSeedRequest'") + print("errMore='"+details+"'") sys.exit(1) - except Exception as err: - print("err='GenSeedRequest'") - print >> sys.stderr, err + except: + e = sys.exc_info()[0] + print >> sys.stderr, e + print("err='GenSeedRequest'") sys.exit(1) request = ln.InitWalletRequest( @@ -110,10 +113,17 @@ if mode=="new": ) try: response = stub.InitWallet(request) + except grpc.RpcError as rpc_error_call: + code = rpc_error_call.code() + print >> sys.stderr, code + details = rpc_error_call.details() + print("err='RPCError InitWallet'") + print("errMore='"+details+"'") + sys.exit(1) except: e = sys.exc_info()[0] print >> sys.stderr, e - print("err='Failed: RPC InitWallet'") + print("err='InitWallet'") sys.exit(1) elif mode=="seed": @@ -125,6 +135,7 @@ elif mode=="seed": ) if len(seedpassword)>0: + print("# running with seed passphrase") request = ln.InitWalletRequest( wallet_password=walletpassword, cipher_seed_mnemonic=seedwords, @@ -133,18 +144,18 @@ elif mode=="seed": ) try: - response = stub.InitWallet(request) - except grpc.RpcError as rpc_error_call: + response = stub.InitWallet(request) + except grpc.RpcError as rpc_error_call: code = rpc_error_call.code() - details = rpc_error_call.details() print >> sys.stderr, code - print >> sys.stderr, details - print("err='Failed: RPCError InitWallet'") + details = rpc_error_call.details() + print("err='RPCError InitWallet'") print("errMore='"+details+"'") + sys.exit(1) except: e = sys.exc_info()[0] print >> sys.stderr, e - print("err='Failed: RPC InitWallet'") + print("err='InitWallet'") sys.exit(1) elif mode=="scb": From 3e811632824b04b3bc4c187f07188bfa5ed9bd54 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:28:47 +0100 Subject: [PATCH 090/162] correct spaces --- home.admin/config.scripts/lnd.initwallet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index f5e2d93..b2b9f61 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -145,7 +145,7 @@ elif mode=="seed": try: response = stub.InitWallet(request) - except grpc.RpcError as rpc_error_call: + except grpc.RpcError as rpc_error_call: code = rpc_error_call.code() print >> sys.stderr, code details = rpc_error_call.details() From 830562476f77bb6d311c7636c38966b3375cee20 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:31:37 +0100 Subject: [PATCH 091/162] debug --- home.admin/config.scripts/lnd.initwallet.py | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index b2b9f61..c6fe36f 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -128,6 +128,7 @@ if mode=="new": elif mode=="seed": + print("# wallet passphrase+ "+walletpassword) request = ln.InitWalletRequest( wallet_password=walletpassword, cipher_seed_mnemonic=seedwords, From 97fc05a07e2c73252c549cec4dcda97adf5b174a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:32:18 +0100 Subject: [PATCH 092/162] debug --- home.admin/config.scripts/lnd.initwallet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index c6fe36f..943ab38 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -128,11 +128,12 @@ if mode=="new": elif mode=="seed": - print("# wallet passphrase+ "+walletpassword) + print("# wallet passphrase: "+walletpassword) request = ln.InitWalletRequest( wallet_password=walletpassword, cipher_seed_mnemonic=seedwords, - recovery_window=1000 + recovery_window=1000, + aezeed_passphrase=seedpassword, ) if len(seedpassword)>0: From 23b1e9dd56576488f5b3925fd0605ac609b83dbd Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 15:36:07 +0100 Subject: [PATCH 093/162] try none --- home.admin/config.scripts/lnd.initwallet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index 943ab38..b1f71a1 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -133,7 +133,7 @@ elif mode=="seed": wallet_password=walletpassword, cipher_seed_mnemonic=seedwords, recovery_window=1000, - aezeed_passphrase=seedpassword, + aezeed_passphrase=None ) if len(seedpassword)>0: From 680ff4684a4e422fc274d05c42cd6b2337841897 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 16:01:57 +0100 Subject: [PATCH 094/162] SCB fallback --- home.admin/70initLND.sh | 277 +++++++++++--------- home.admin/config.scripts/lnd.initwallet.py | 15 +- 2 files changed, 159 insertions(+), 133 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 93141a3..8dc58db 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -213,7 +213,17 @@ if [ ${walletExists} -eq 0 ]; then ONLYSEED "Only Seed Word List (FALLBACK)") CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) - # show warn when only seed + # LND RESCUE + if [ "${CHOICE}" == "LNDRESCUE" ]; then + sudo /home/admin/config.scripts/lnd.rescue.sh restore + echo "" + echo "PRESS ENTER to continue." + read key + /home/admin/70initLND.sh + exit 1 + fi + + # WRNING ON ONLY SEED if [ "${CHOICE}" == "ONLYSEED" ]; then whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno " Using JUST SEED WORDS will only recover your on-chain funds. @@ -227,88 +237,89 @@ or having a complete LND rescue-backup from your old node. fi fi - # let user enter password c - sudo shred /home/admin/.pass.tmp 2>/dev/null - sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp - passwordC=`sudo cat /home/admin/.pass.tmp` - sudo shred /home/admin/.pass.tmp 2>/dev/null - - # get seed word list - if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then - - # dialog to enter - dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp - wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9,]//g' ) - shred /home/admin/.seed.tmp - echo "processing ... ${wordstring}" - - # check correct number of words - IFS=',' read -r -a seedArray <<< "$wordstring" - if [ ${#seedArray[@]} -eq 24 ]; then - echo "OK - 24 words" - else - whiptail --title " WARNING " --msgbox " -The word list has ${#seedArray[@]} words. But it must be 24. -Please check your list and try again. - -Best is to write words in external editor -and then copy and paste them into dialog. - -The Word list should look like this: -wordone,wordtweo,wordthree, ... - -" 16 52 - /home/admin/70initLND.sh - exit 1 - fi - - # ask if seed was protected by password D - passwordD="" - dialog --title "SEED PASSWORD" --yes-button "No extra Password" --no-button "Yes" --yesno " -Are your seed words protected by an extra password? - -During wallet creation LND offers to set an extra password -to protect the seed words. Most users did not set this. - " 11 65 - if [ $? -eq 1 ]; then - sudo shred /home/admin/.pass.tmp 2>/dev/null - sudo ./config.scripts/blitz.setpassword.sh x "Enter extra Password D" /home/admin/.pass.tmp - passwordD=`sudo cat /home/admin/.pass.tmp` - sudo shred /home/admin/.pass.tmp 2>/dev/null - fi - - fi - - if [ "${CHOICE}" == "ONLYSEED" ]; then - - # trigger wallet recovery - source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} ${passwordD}) - - # on success the python script should return the seed words again - if [ ${#seedwords} -gt 1 ]; then - dialog --title " SUCCESS " --msgbox " -Looks good :) LND was able to recover the wallet. - " 7 53 - else - if [ ${#err} -eq 0 ]; then - echo - echo "FAIL!! Unkown Error - check output above for any hints and report to development." - echo "PRESS ENTER to try again." - read key - /home/admin/70initLND.sh - exit 1 - else - whiptail --title " FAIL " --msgbox " -Something went wrong - see info below: -${err} -${errMore} - " 13 72 - /home/admin/70initLND.sh - exit 1 - fi - fi - - elif [ "${CHOICE}" == "SEED+SCB" ]; then +##### DEACTIVATED UNTIL config.scripts/lnd.initwallet.py WORKS +# # let user enter password c +# sudo shred /home/admin/.pass.tmp 2>/dev/null +# sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp +# passwordC=`sudo cat /home/admin/.pass.tmp` +# sudo shred /home/admin/.pass.tmp 2>/dev/null +# +# # get seed word list +# if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then +# +# # dialog to enter +# dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by commas, in correct order as numbered)" 9 78 2>/home/admin/.seed.tmp +# wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9,]//g' ) +# shred /home/admin/.seed.tmp +# echo "processing ... ${wordstring}" +# +# # check correct number of words +# IFS=',' read -r -a seedArray <<< "$wordstring" +# if [ ${#seedArray[@]} -eq 24 ]; then +# echo "OK - 24 words" +# else +# whiptail --title " WARNING " --msgbox " +#The word list has ${#seedArray[@]} words. But it must be 24. +#Please check your list and try again. +# +#Best is to write words in external editor +#and then copy and paste them into dialog. +# +#The Word list should look like this: +#wordone,wordtweo,wordthree, ... +# +#" 16 52 +# /home/admin/70initLND.sh +# exit 1 +# fi +# +# # ask if seed was protected by password D +# passwordD="" +# dialog --title "SEED PASSWORD" --yes-button "No extra Password" --no-button "Yes" --yesno " +#Are your seed words protected by an extra password? +# +#During wallet creation LND offers to set an extra password +#to protect the seed words. Most users did not set this. +# " 11 65 +# if [ $? -eq 1 ]; then +# sudo shred /home/admin/.pass.tmp 2>/dev/null +# sudo ./config.scripts/blitz.setpassword.sh x "Enter extra Password D" /home/admin/.pass.tmp +# passwordD=`sudo cat /home/admin/.pass.tmp` +# sudo shred /home/admin/.pass.tmp 2>/dev/null +# fi +# +# fi +# +# if [ "${CHOICE}" == "ONLYSEED" ]; then +# +# # trigger wallet recovery +# source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} ${passwordD}) +# +# # on success the python script should return the seed words again +# if [ ${#seedwords} -gt 1 ]; then +# dialog --title " SUCCESS " --msgbox " +#Looks good :) LND was able to recover the wallet. +# " 7 53 +# else +# if [ ${#err} -eq 0 ]; then +# echo +# echo "FAIL!! Unkown Error - check output above for any hints and report to development." +# echo "PRESS ENTER to try again." +# read key +# /home/admin/70initLND.sh +# exit 1 +# else +# whiptail --title " FAIL " --msgbox " +#Something went wrong - see info below: +#${err} +#${errMore} +# " 13 72 +# /home/admin/70initLND.sh +# exit 1 +# fi +# fi +# fi + if [ "${CHOICE}" == "SEED+SCB" ]; then # get the channel.backup file gotFile=-1 @@ -348,59 +359,69 @@ ${errMore} fi # test upload - gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup') + gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup') done clear echo "OK - channel.backup file found." - # trigger wallet recovery - source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} /home/admin/channel.backup ${passwordD}) - # WIN/FAIL User feedback - # on success the python script should return the seed words again - if [ ${#seedwords} -gt 1 ]; then - dialog --title " SUCCESS " --msgbox " -Looks good :) LND was able to recover the wallet. - " 7 53 - else - if [ ${#err} -eq 0 ]; then - echo - echo "FAIL!! Unkown Error - check output above for any hints and report to development." - echo "PRESS ENTER to try again." - read key - /home/admin/70initLND.sh - exit 1 - else - whiptail --title " FAIL " --msgbox " -Something went wrong - see info below: -${err} -${errMore} - " 13 72 - /home/admin/70initLND.sh - exit 1 - fi - fi +##### FALLBACK UNTIL config.scripts/lnd.initwallet.py WORKS + echo "****************************************************************************" + echo "Helping Instructions --> for recovering a LND Wallet" + echo "****************************************************************************" + echo "A) For 'Wallet Password' use your old PASSWORD C" + echo "B) For 'cipher seed mnemonic' answere 'y' and enter words sepereted by space" + echo "C) Enter 'passphrase' to encrypt your 'cipher seed' only if u did on create" + echo "****************************************************************************" + echo "" + sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>$_error + error=`cat ${_error}` - elif [ "${CHOICE}" == "LNDRESCUE" ]; then - sudo /home/admin/config.scripts/lnd.rescue.sh restore + if [ ${#error} -gt 0 ]; then echo "" - echo "PRESS ENTER to continue." + echo "!!! FAIL !!! SOMETHING WENT WRONG:" + echo "${error}" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "" + echo "Press ENTER to retry ..." read key - /home/admin/70initLND.sh - exit 1 - - else - echo "CANCEL" + echo "Starting RETRY ..." /home/admin/70initLND.sh exit 1 fi - # FALLBACK - #dialog --title "OK" --msgbox "\nI will start 'lncli create' for you ..." 7 44 - #sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create - #/home/admin/70initLND.sh + /home/admin/70initLND.sh + +##### DEACTIVATED UNTIL config.scripts/lnd.initwallet.py WORKS +# # trigger wallet recovery +# source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} /home/admin/channel.backup ${passwordD}) +# +# # WIN/FAIL User feedback +# # on success the python script should return the seed words again +# if [ ${#seedwords} -gt 1 ]; then +# dialog --title " SUCCESS " --msgbox " +#Looks good :) LND was able to recover the wallet. +# " 7 53 +# else +# if [ ${#err} -eq 0 ]; then +# echo +# echo "FAIL!! Unkown Error - check output above for any hints and report to development." +# echo "PRESS ENTER to try again." +# read key +# /home/admin/70initLND.sh +# exit 1 +# else +# whiptail --title " FAIL " --msgbox " +#Something went wrong - see info below: +#${err} +#${errMore} +# " 13 72 +# /home/admin/70initLND.sh +# exit 1 +# fi +# fi fi @@ -458,6 +479,18 @@ if [ ${locked} -gt 0 ]; then else echo "OK - Wallet is already unlocked" fi +echo "" + +###### USE CHANNEL.BACKUP FILE IF AVAILABLE +echo "*** SCB Recovery ***" +gotSCB=$(ls /home/admin/channel.backup | grep -c 'channel.backup') +if [ ${gotSCB} -eq 1 ]; then + lncli restorechanbackup --multi_file=/home/admin/channel.backup +else + echo "NO /home/admin/channel.backup file - skipping SCB" +fi +echo "PRESS ENTER" +read key # set SetupState (scan is done - so its 80%) sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py index b1f71a1..bad4641 100644 --- a/home.admin/config.scripts/lnd.initwallet.py +++ b/home.admin/config.scripts/lnd.initwallet.py @@ -128,23 +128,16 @@ if mode=="new": elif mode=="seed": - print("# wallet passphrase: "+walletpassword) + print("err='TODO: debug creating from seed") + sys.exit(1) + request = ln.InitWalletRequest( wallet_password=walletpassword, cipher_seed_mnemonic=seedwords, recovery_window=1000, - aezeed_passphrase=None + aezeed_passphrase=seedpassword ) - if len(seedpassword)>0: - print("# running with seed passphrase") - request = ln.InitWalletRequest( - wallet_password=walletpassword, - cipher_seed_mnemonic=seedwords, - aezeed_passphrase=seedpassword, - recovery_window=1000 - ) - try: response = stub.InitWallet(request) except grpc.RpcError as rpc_error_call: From e363727d7543a970299b458ccb10911c3e33ba67 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 16:03:55 +0100 Subject: [PATCH 095/162] repair if --- home.admin/70initLND.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 8dc58db..e0df770 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -365,7 +365,7 @@ or having a complete LND rescue-backup from your old node. clear echo "OK - channel.backup file found." - + fi ##### FALLBACK UNTIL config.scripts/lnd.initwallet.py WORKS echo "****************************************************************************" @@ -421,9 +421,8 @@ or having a complete LND rescue-backup from your old node. # /home/admin/70initLND.sh # exit 1 # fi -# fi - - fi +# fi + fi # END OLD WALLET else echo "OK - LND wallet already exists." From a7c8f12c620b57d72a75f5d63ce02a8a840aa682 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 16:05:14 +0100 Subject: [PATCH 096/162] fix error output --- home.admin/70initLND.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index e0df770..1d12f8e 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -376,8 +376,9 @@ or having a complete LND rescue-backup from your old node. echo "C) Enter 'passphrase' to encrypt your 'cipher seed' only if u did on create" echo "****************************************************************************" echo "" - sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>$_error - error=`cat ${_error}` + sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>/home/admin/.error.tmp + error=`cat /home/admin/.error.tmp` + rm /home/admin/.error.tmp 2>/dev/null if [ ${#error} -gt 0 ]; then echo "" From 2b929c5680fd4c81a6b7a047b3075fafac09b433 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 17:13:10 +0100 Subject: [PATCH 097/162] Update Info on Recover --- home.admin/70initLND.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 1d12f8e..2e00b6e 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -372,8 +372,9 @@ or having a complete LND rescue-backup from your old node. echo "Helping Instructions --> for recovering a LND Wallet" echo "****************************************************************************" echo "A) For 'Wallet Password' use your old PASSWORD C" - echo "B) For 'cipher seed mnemonic' answere 'y' and enter words sepereted by space" - echo "C) Enter 'passphrase' to encrypt your 'cipher seed' only if u did on create" + echo "B) For 'cipher seed mnemonic' answere 'y' and then enter your seed words" + echo "C) On 'cipher seed passphrase' ONLY enter PASSWORD D if u used it on create" + echo "D) On 'address look-ahead' only enter more than 2500 had lots of channels" echo "****************************************************************************" echo "" sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>/home/admin/.error.tmp @@ -485,7 +486,23 @@ echo "" echo "*** SCB Recovery ***" gotSCB=$(ls /home/admin/channel.backup | grep -c 'channel.backup') if [ ${gotSCB} -eq 1 ]; then - lncli restorechanbackup --multi_file=/home/admin/channel.backup + + lncli restorechanbackup --multi_file=/home/admin/channel.backup 2>/home/admin/.error.tmp + error=`cat /home/admin/.error.tmp` + rm /home/admin/.error.tmp 2>/dev/null + + if [ ${#error} -gt 0 ]; then + echo "" + echo "!!! FAIL !!! SOMETHING WENT WRONG:" + echo "${error}" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "" + echo "You can try after full setup to restore channel.backup file again." + echo "Press ENTER to continue ..." + read key + exit 1 + fi + else echo "NO /home/admin/channel.backup file - skipping SCB" fi From 178ba89eaf95dbe47f3f49b8001e23ddfe50c7cd Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 17:13:19 +0100 Subject: [PATCH 098/162] #524 check update script --- home.admin/99checkBackup.sh | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 home.admin/99checkBackup.sh diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh new file mode 100644 index 0000000..f22d3ca --- /dev/null +++ b/home.admin/99checkBackup.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# load raspiblitz config data +source /home/admin/raspiblitz.info +source /mnt/hdd/raspiblitz.conf +source /home/admin/_version.info + +clear + +# get latest release verison from GitHub +sudo curl -s -X GET https://raw.githubusercontent.com/rootzoll/raspiblitz/master/home.admin/_version.info > /home/admin/.version.tmp +gitHubVersionMain=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") +gitHubVersionSub=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") +sudo shred /home/admin/.version.tmp +sudo rm /home/admin/.version.tmp 2>/dev/null + +# check valid version info +if [ ${#gitHubVersionMain} -eq 0 ] || [ ${#gitHubVersionSub} -eq 0 ]; then + echo "FAIL: Was not able to get latest release Version from GitHub." + echo "PRESS ENTER to continue." + read key + exit 1 +fi + +# get local version +localVersionMain=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") +localVersionSub=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") + +# compare versions +newerVersionAvailable=0 +if [ ${gitHubVersionMain} -gt ${localVersionMain} ]; then + echo "Main version is higher ..." + newerVersionAvailable=1 +else + if [ ${gitHubVersionSub} -gt ${localVersionSub} ]; then + echo "Sub version is higher ..." + newerVersionAvailable=1 + fi +fi + +# give feedback on version number +if [ ${newerVersionAvailable} -eq 0 ]; then + echo "You have the latest version running." +else + echo "New Version available on the RaspiBlitz Repo." +fi + + + + + + From 82a6953c86cf43371796b42cf471ed812cb93e33 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 17:16:39 +0100 Subject: [PATCH 099/162] add debug --- home.admin/99checkBackup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index f22d3ca..5aa0abb 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -26,13 +26,18 @@ fi localVersionMain=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") localVersionSub=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") +echo "local version: ${gitHubVersionMain}.${gitHubVersionSub}" +echo "github version: ${localVersionMain}.${localVersionSub}" + # compare versions newerVersionAvailable=0 if [ ${gitHubVersionMain} -gt ${localVersionMain} ]; then echo "Main version is higher ..." newerVersionAvailable=1 else - if [ ${gitHubVersionSub} -gt ${localVersionSub} ]; then + if [ ${gitHubVersionMain} -lt ${localVersionMain} ]; then + echo "Strange that GutHub main version is lower then local - you maybe using a early release." + elif [ ${gitHubVersionSub} -gt ${localVersionSub} ]; then echo "Sub version is higher ..." newerVersionAvailable=1 fi From 37ad4699e39bda8f66faff7ad5bf396c7ed3a0c0 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 17:17:52 +0100 Subject: [PATCH 100/162] fix version cut --- home.admin/99checkBackup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index 5aa0abb..d3a01b4 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -10,7 +10,7 @@ clear # get latest release verison from GitHub sudo curl -s -X GET https://raw.githubusercontent.com/rootzoll/raspiblitz/master/home.admin/_version.info > /home/admin/.version.tmp gitHubVersionMain=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") -gitHubVersionSub=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") +gitHubVersionSub=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f2 | egrep "^[0-9]") sudo shred /home/admin/.version.tmp sudo rm /home/admin/.version.tmp 2>/dev/null @@ -24,7 +24,7 @@ fi # get local version localVersionMain=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") -localVersionSub=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") +localVersionSub=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f2 | egrep "^[0-9]") echo "local version: ${gitHubVersionMain}.${gitHubVersionSub}" echo "github version: ${localVersionMain}.${localVersionSub}" From 549028c3d1c680a79232ef196e24f7eb02091b20 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:05:03 +0100 Subject: [PATCH 101/162] Update Prepare Process --- home.admin/99checkBackup.sh | 74 +++++++++++++++++++++++-- home.admin/config.scripts/lnd.rescue.sh | 8 ++- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index d3a01b4..ef14469 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -26,8 +26,8 @@ fi localVersionMain=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]") localVersionSub=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f2 | egrep "^[0-9]") -echo "local version: ${gitHubVersionMain}.${gitHubVersionSub}" -echo "github version: ${localVersionMain}.${localVersionSub}" +echo "github version: ${gitHubVersionMain}.${gitHubVersionSub}" +echo "local version: ${localVersionMain}.${localVersionSub}" # compare versions newerVersionAvailable=0 @@ -45,9 +45,75 @@ fi # give feedback on version number if [ ${newerVersionAvailable} -eq 0 ]; then - echo "You have the latest version running." + dialog --title " Update Check " --msgbox " +OK. You are running the newest version of RaspiBlitz. + " 7 57 + exit 0 else - echo "New Version available on the RaspiBlitz Repo." + whiptail --title "Update Check" --yes-button "Yes" --no-button "Not Now" --yesno " +There is a new Version of RaspiBlitz available. +You are running: ${localVersionMain}.${localVersionSub} +New Version: ${gitHubVersionMain}.${gitHubVersionSub} + +Do you want more Information on how to update? + " 12 52 + if [ $? -eq 1 ]; then + exit 1 + fi + + whiptail --title "Update Instructions" --yes-button "Not Now" --no-button "Start Update" --yesno "To update your RaspiBlitz to a new version: + +- Download the new SD card image to your laptop: + https://github.com/rootzoll/raspiblitz +- Flash that SD card image to a new SD card +- Choose 'Start Update' below. + +No need to close channels or download blockchain again. + +Do you want to start the Update now? + " 16 62 + if [ $? -eq 0 ]; then + exit 1 + fi + + whiptail --title "LND Data Backup" --yes-button "Download Backup" --no-button "Skip" --yesno " +Before we start the RaspiBlitz Update process, +its recommended to make a backup of all your LND Data +and download that file to your laptop. + +Do you want to download LND Data Backup now? + " 12 58 + if [ $? -eq 0 ]; then + /home/admin/config.scripts/lnd.rescue.sh backup + else + clear + echo "*************************************" + echo "* JUST MAKING BACKUP TO OLD SD CARD" + echo "*************************************" + echo "please wait .." + sleep 2 + /home/admin/config.scripts/lnd.rescue.sh backup no-download + fi + + whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down. +Once the LCD is white and no LEDs are blicking anymore: + +- Remove the Power from RaspiBlitz +- Exchange the old with the new SD card +- Connect Power back to the RaspiBlitz +- Follow the instructions on the LCD + +Do you have the SD card with the new version image ready +and do you WANT TO START UPDATE NOW? + " 16 62 + + if [ $? -eq 1 ]; then + exit 1 + fi + + echo "TODO: RUN UPDATE NOW" + exit 1 + fi diff --git a/home.admin/config.scripts/lnd.rescue.sh b/home.admin/config.scripts/lnd.rescue.sh index 8a6f154..611cb02 100755 --- a/home.admin/config.scripts/lnd.rescue.sh +++ b/home.admin/config.scripts/lnd.rescue.sh @@ -3,7 +3,7 @@ # command info if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo "small rescue script to to backup or restore" - echo "lnd.rescue.sh [backup|restore]" + echo "lnd.rescue.sh [backup|restore] [?no-download]" exit 1 fi @@ -36,6 +36,12 @@ if [ ${mode} = "backup" ]; then md5checksum=$(md5sum /home/admin/lnd-rescue.tar.gz | head -n1 | cut -d " " -f1) mv /home/admin/lnd-rescue.tar.gz /home/admin/lnd-rescue-${md5checksum}.tar.gz + # stop here in case of 'no-download' option + if [ "${2}" == "no-download" ]; then + echo "No download of LND data requested." + exit 0 + fi + # offer SCP for download echo echo "****************************" From 93403023caefab80bb5936686acc9b8e667d6498 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:07:38 +0100 Subject: [PATCH 102/162] update anyway option --- home.admin/99checkBackup.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index ef14469..f25a78a 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -45,11 +45,14 @@ fi # give feedback on version number if [ ${newerVersionAvailable} -eq 0 ]; then - dialog --title " Update Check " --msgbox " + dialog --title " Update Check " --yes-button "OK" --no-button "Update Anyway" --yesno " OK. You are running the newest version of RaspiBlitz. " 7 57 - exit 0 -else + if [ $? -eq 0 ]; then + exit 1 + fi +fi + whiptail --title "Update Check" --yes-button "Yes" --no-button "Not Now" --yesno " There is a new Version of RaspiBlitz available. You are running: ${localVersionMain}.${localVersionSub} From d57ec6dbe900dcc9b7b10aee91ddc76fb3fd4a09 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:09:30 +0100 Subject: [PATCH 103/162] Update Anyway Option --- home.admin/99checkBackup.sh | 51 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index f25a78a..133796b 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -51,7 +51,7 @@ OK. You are running the newest version of RaspiBlitz. if [ $? -eq 0 ]; then exit 1 fi -fi +else whiptail --title "Update Check" --yes-button "Yes" --no-button "Not Now" --yesno " There is a new Version of RaspiBlitz available. @@ -63,8 +63,9 @@ Do you want more Information on how to update? if [ $? -eq 1 ]; then exit 1 fi +fi - whiptail --title "Update Instructions" --yes-button "Not Now" --no-button "Start Update" --yesno "To update your RaspiBlitz to a new version: +whiptail --title "Update Instructions" --yes-button "Not Now" --no-button "Start Update" --yesno "To update your RaspiBlitz to a new version: - Download the new SD card image to your laptop: https://github.com/rootzoll/raspiblitz @@ -75,30 +76,30 @@ No need to close channels or download blockchain again. Do you want to start the Update now? " 16 62 - if [ $? -eq 0 ]; then - exit 1 - fi +if [ $? -eq 0 ]; then + exit 1 +fi - whiptail --title "LND Data Backup" --yes-button "Download Backup" --no-button "Skip" --yesno " +whiptail --title "LND Data Backup" --yes-button "Download Backup" --no-button "Skip" --yesno " Before we start the RaspiBlitz Update process, its recommended to make a backup of all your LND Data and download that file to your laptop. Do you want to download LND Data Backup now? " 12 58 - if [ $? -eq 0 ]; then - /home/admin/config.scripts/lnd.rescue.sh backup - else - clear - echo "*************************************" - echo "* JUST MAKING BACKUP TO OLD SD CARD" - echo "*************************************" - echo "please wait .." - sleep 2 - /home/admin/config.scripts/lnd.rescue.sh backup no-download - fi +if [ $? -eq 0 ]; then + /home/admin/config.scripts/lnd.rescue.sh backup +else + clear + echo "*************************************" + echo "* JUST MAKING BACKUP TO OLD SD CARD" + echo "*************************************" + echo "please wait .." + sleep 2 + /home/admin/config.scripts/lnd.rescue.sh backup no-download +fi - whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down. +whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down. Once the LCD is white and no LEDs are blicking anymore: - Remove the Power from RaspiBlitz @@ -110,17 +111,9 @@ Do you have the SD card with the new version image ready and do you WANT TO START UPDATE NOW? " 16 62 - if [ $? -eq 1 ]; then - exit 1 - fi - - echo "TODO: RUN UPDATE NOW" +if [ $? -eq 1 ]; then exit 1 - fi - - - - - +echo "TODO: RUN UPDATE NOW" +exit 1 \ No newline at end of file From 037e0f89a834c4c2cd3a9b3a79e974231e35b052 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:14:19 +0100 Subject: [PATCH 104/162] restart lnd if needed --- home.admin/99checkBackup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index 133796b..59ae535 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -51,6 +51,7 @@ OK. You are running the newest version of RaspiBlitz. if [ $? -eq 0 ]; then exit 1 fi + clear else whiptail --title "Update Check" --yes-button "Yes" --no-button "Not Now" --yesno " @@ -112,6 +113,10 @@ and do you WANT TO START UPDATE NOW? " 16 62 if [ $? -eq 1 ]; then + dialog --title " Update Canceled " --msgbox " +OK. RaspiBlitz will NOT update now. + " 7 39 + sudo systemctl start lnd exit 1 fi From 2fb7d74c505228f71faf37e457073eec6b8479b1 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:23:02 +0100 Subject: [PATCH 105/162] debug --- home.admin/99checkBackup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index 59ae535..475a483 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -89,7 +89,14 @@ and download that file to your laptop. Do you want to download LND Data Backup now? " 12 58 if [ $? -eq 0 ]; then + clear + echo "*************************************" + echo "* PREPARING LND BACKUP DOWNLOAD" + echo "*************************************" + echo "please wait .." + sleep 2 /home/admin/config.scripts/lnd.rescue.sh backup + read key else clear echo "*************************************" @@ -98,6 +105,7 @@ else echo "please wait .." sleep 2 /home/admin/config.scripts/lnd.rescue.sh backup no-download + read key fi whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down. From 5e75ac785bcfab502b0e9547cce229228fa9a336 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:26:18 +0100 Subject: [PATCH 106/162] download wait --- home.admin/99checkBackup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkBackup.sh index 475a483..efd9b5e 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkBackup.sh @@ -96,6 +96,8 @@ if [ $? -eq 0 ]; then echo "please wait .." sleep 2 /home/admin/config.scripts/lnd.rescue.sh backup + echo + echo "PRESS ENTER to continue once your done downloading." read key else clear @@ -105,7 +107,6 @@ else echo "please wait .." sleep 2 /home/admin/config.scripts/lnd.rescue.sh backup no-download - read key fi whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down. From 61cdc025012f2703e6a5d6fc83b52c0a96a14ea4 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:31:36 +0100 Subject: [PATCH 107/162] #524 added Update to main menu --- home.admin/00mainMenu.sh | 12 +++++++++--- home.admin/{99checkBackup.sh => 99checkUpdate.sh} | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) rename home.admin/{99checkBackup.sh => 99checkUpdate.sh} (99%) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 21cb827..24cb971 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -377,9 +377,10 @@ else fi # final Options - OPTIONS+=(HARDWARE "Run Hardwaretest") - OPTIONS+=(SOFTWARE "Run Softwaretest") - OPTIONS+=(OFF "PowerOff RaspiBlitz") + OPTIONS+=(HARDWARE "Run Hardwaretest") + OPTIONS+=(SOFTWARE "Run Softwaretest") + OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update") + OPTIONS+=(OFF "PowerOff RaspiBlitz") OPTIONS+=(X "Console / Terminal") fi @@ -576,6 +577,11 @@ case $CHOICE in sudo shutdown -r now exit 0 ;; + UPDATE) + /home/admin/99checkUpdate.sh + ./00mainMenu.sh + exit 0 + ;; X) lncli -h echo "OK you now on the command line." diff --git a/home.admin/99checkBackup.sh b/home.admin/99checkUpdate.sh similarity index 99% rename from home.admin/99checkBackup.sh rename to home.admin/99checkUpdate.sh index efd9b5e..92af3f4 100644 --- a/home.admin/99checkBackup.sh +++ b/home.admin/99checkUpdate.sh @@ -129,5 +129,5 @@ OK. RaspiBlitz will NOT update now. exit 1 fi -echo "TODO: RUN UPDATE NOW" -exit 1 \ No newline at end of file +clear +sudo shutdown now \ No newline at end of file From 10ff1fe8345bd19651c91acc7f5885fc6ffac599 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 18:55:25 +0100 Subject: [PATCH 108/162] refactor main menu --- build_sdcard.sh | 2 +- home.admin/00mainMenu.sh | 459 ++++-------------------------------- home.admin/00raspiblitz.sh | 390 ++++++++++++++++++++++++++++++ home.admin/50downloadHDD.sh | 2 +- home.admin/50torrentHDD.sh | 2 +- home.admin/_commands.sh | 2 +- 6 files changed, 436 insertions(+), 421 deletions(-) create mode 100755 home.admin/00raspiblitz.sh diff --git a/build_sdcard.sh b/build_sdcard.sh index c0760b8..98477e5 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -600,7 +600,7 @@ sudo bash -c "echo 'PATH=\$PATH:\$GOPATH/bin' >> /home/admin/.profile" sudo bash -c "echo '# shortcut commands' >> /home/admin/.bashrc" sudo bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc" sudo bash -c "echo '# automatically start main menu for admin' >> /home/admin/.bashrc" -sudo bash -c "echo './00mainMenu.sh' >> /home/admin/.bashrc" +sudo bash -c "echo './00raspiblitz.sh' >> /home/admin/.bashrc" if [ "${baseImage}" = "raspbian" ]; then # bash autostart for pi diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 24cb971..7ab116f 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -7,385 +7,59 @@ configFile="/mnt/hdd/raspiblitz.conf" # INFOFILE - state data from bootstrap infoFile="/home/admin/raspiblitz.info" -# check if HDD is connected -hddExists=$(lsblk | grep -c sda1) -if [ ${hddExists} -eq 0 ]; then - - # check if there is maybe a HDD but woth no partitions - noPartition=$(lsblk | grep -c sda) - if [ ${noPartition} -eq 1 ]; then - echo "***********************************************************" - echo "WARNING: HDD HAS NO PARTITIONS" - echo "***********************************************************" - echo "Press ENTER to create a Partition - or CTRL+C to abort" - read key - echo "Creating Partition ..." - sudo parted -s /dev/sda unit s mkpart primary `sudo parted /dev/sda unit s print free | grep 'Free Space' | tail -n 1` - echo "DONE." - sleep 3 - else - echo "***********************************************************" - echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart." - echo "***********************************************************" - exit - fi -fi - -# check data from _bootstrap.sh that was running on device setup -bootstrapInfoExists=$(ls $infoFile | grep -c '.info') -if [ ${bootstrapInfoExists} -eq 0 ]; then - echo "***********************************************************" - echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?" - echo "***********************************************************" - exit -fi - -# load the data from the info file (will get produced on every startup) +# MAIN MENU AFTER SETUP source ${infoFile} +source ${configFile} -if [ "${state}" = "recovering" ]; then - echo "***********************************************************" - echo "WARNING: bootstrap still updating - close SSH, login later" - echo "To monitor progress --> tail -n1000 -f raspiblitz.log" - echo "***********************************************************" - exit +# Backtitle Info +plus="" +if [ "${runBehindTor}" = "on" ]; then + plus=" / TOR" fi - -# signal that after bootstrap recover user dialog is needed -if [ "${state}" = "recovered" ]; then - echo "System recovered - needs final user settings" - ./20recoverDialog.sh - exit 1 +if [ ${#dynDomain} -gt 0 ]; then + plus="${plus} / ${dynDomain}" fi - -# signal that a reindex was triggered -if [ "${state}" = "reindex" ]; then - echo "Re-Index in progress ... start monitoring:" - /home/admin/config.scripts/network.reindex.sh - exit 1 +BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}" +if [ ${runningRTL} -eq 1 ]; then + TITLE="Webinterface: http://${localip}:3000" fi -# singal that torrent is in re-download -if [ "${state}" = "retorrent" ]; then - echo "Re-Index in progress ... start monitoring:" - /home/admin/50torrentHDD.sh - sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info - /home/admin/00mainMenu.sh - exit +# Basic Options +OPTIONS+=(INFO "RaspiBlitz Status Screen" \ + FUNDING "Fund your on-chain Wallet" \ + CONNECT "Connect to a Peer" \ + CHANNEL "Open a Channel with Peer" \ + SEND "Pay an Invoice/PaymentRequest" \ + RECEIVE "Create Invoice/PaymentRequest" \ + SERVICES "Activate/Deactivate Services" \ + MOBILE "Connect Mobile Wallet" \ + EXPORT "Macaroons and TLS.cert" \ + NAME "Change Name/Alias of Node" \ + PASSWORD "Change Passwords" \ + CASHOUT "Remove Funds from on-chain Wallet" +) + +# dont offer lnbalance/lnchannels on testnet +if [ "${chain}" = "main" ]; then + OPTIONS+=(lnbalance "Detailed Wallet Balances" \ + lnchannels "Lightning Channel List") fi -# if pre-sync is running - stop it - before continue -if [ "${state}" = "presync" ]; then - # stopping the pre-sync - echo "" - # analyse if blockchain was detected broken by pre-sync - blockchainBroken=$(sudo tail /mnt/hdd/bitcoin/debug.log | grep -c "Please restart with -reindex or -reindex-chainstate to recover.") - if [ ${blockchainBroken} -eq 1 ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Detected corrupted blockchain on pre-sync !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Deleting blockchain data ..." - echo "(needs to get downloaded fresh during setup)" - sudo rm -f -r /mnt/hdd/bitcoin - else - echo "********************************************" - echo "Stopping pre-sync ... pls wait (up to 1min)" - echo "********************************************" - sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop - echo "bitcoind called to stop .." - sleep 50 - fi - - # unmount the temporary mount - echo "Unmount HDD .." - sudo umount -l /mnt/hdd - sleep 3 - - # update info file - state=waitsetup - sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile - sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile +# Depending Options +openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length') +if [ ${openChannels} -gt 0 ]; then + OPTIONS+=(CLOSEALL "Close all open Channels") fi - -# if state=ready -> setup is done or started -if [ "${state}" = "ready" ]; then - configExists=$(ls ${configFile} | grep -c '.conf') - if [ ${configExists} -eq 1 ]; then - echo "loading config data" - source ${configFile} - else - echo "setup still in progress - setupStep(${setupStep})" - fi -fi - -## default menu settings -# to fit the main menu without scrolling: -# HEIGHT=23 -# CHOICE_HEIGHT=20 -HEIGHT=13 -WIDTH=64 -CHOICE_HEIGHT=6 -BACKTITLE="RaspiBlitz" -TITLE="" -MENU="Choose one of the following options:" -OPTIONS=() - -# check if RTL web interface is installed -runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') - -# get the local network IP to be displayed on the lCD -localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - -# function to use later -waitUntilChainNetworkIsReady() -{ - echo "checking ${network}d - please wait .." - echo "can take longer if device was off or first time" - while : - do - - # check for error on network - sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp - clienterror=`cat error.tmp` - rm error.tmp - - # check for missing blockchain data - minSize=250000000000 - if [ "${network}" = "litecoin" ]; then - minSize=20000000000 - fi - blockchainsize=$(sudo du -shbc /mnt/hdd/${network} | head -n1 | awk '{print $1;}') - if [ ${#blockchainsize} -gt 0 ]; then - if [ ${blockchainsize} -lt ${minSize} ]; then - echo "blockchainsize(${blockchainsize})" - echo "Missing Blockchain Data (<${minSize}) ..." - clienterror="missing blockchain" - sleep 3 - fi - fi - - if [ ${#clienterror} -gt 0 ]; then - - # analyse LOGS for possible reindex - reindex=$(sudo cat /mnt/hdd/${network}/debug.log | grep -c 'Please restart with -reindex or -reindex-chainstate to recover') - if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then - echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options." - sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info - sleep 3 - - dialog --backtitle "RaspiBlitz - Repair Script" --msgbox "Your blockchain data needs to be repaired. -This can be due to power problems or a failing HDD. -Please check the FAQ on RaspiBlitz Github -'My blockchain data is corrupted - what can I do?' -https://github.com/rootzoll/raspiblitz/blob/master/FAQ.md - -The RaspiBlitz will now try to help you on with the repair. -To run a BACKUP of funds & channels first is recommended. -" 13 65 - - clear - # Basic Options - OPTIONS=(TORRENT "Redownload Prepared Torrent (DEFAULT)" \ - COPY "Copy from another Computer (SKILLED)" \ - REINDEX "Resync thru ${network}d (TAKES VERY VERY LONG)" \ - BACKUP "Run Backup LND data first (optional)" - ) - - CHOICE=$(dialog --backtitle "RaspiBlitz - Repair Script" --clear --title "Repair Blockchain Data" --menu "Choose a repair/recovery option:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) - - clear - if [ "${CHOICE}" = "TORRENT" ]; then - echo "Starting TORRENT ..." - sudo sed -i "s/^state=.*/state=retorrent/g" /home/admin/raspiblitz.info - /home/admin/50torrentHDD.sh - sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info - /home/admin/00mainMenu.sh - exit - - elif [ "${CHOICE}" = "COPY" ]; then - echo "Starting COPY ..." - sudo sed -i "s/^state=.*/state=recopy/g" /home/admin/raspiblitz.info - /home/admin/50copyHDD.sh - sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info - /home/admin/00mainMenu.sh - exit - - elif [ "${CHOICE}" = "REINDEX" ]; then - echo "Starting REINDEX ..." - sudo /home/admin/config.scripts/network.reindex.sh - exit - - elif [ "${CHOICE}" = "BACKUP" ]; then - sudo /home/admin/config.scripts/lnd.rescue.sh backup - echo "PRESS ENTER to return to menu." - read key - /home/admin/00mainMenu.sh - exit - - else - echo "CANCEL" - exit - fi - - else - echo "${network} error: ${clienterror}" - fi - - # normal info - boxwidth=40 - l1="Waiting for ${network}d to get ready.\n" - l2="---> ${clienterror/error*:/}\n" - l3="Can take longer if device was off." - uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')" - # after 2 min show complete long string (full detail) - if [ ${uptimeSeconds} -gt 120 ]; then - boxwidth=80 - l2="${clienterror}\n" - l3="CTRL+C => terminal" - fi - dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth} - else - locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) - if [ ${locked} -gt 0 ]; then - ./AAunlockLND.sh - echo "please wait ... update to next screen can be slow" - fi - lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) - if [ ${lndSynced} -eq 0 ]; then - ./80scanLND.sh - else - # everything is ready - return from loop - return - fi - fi - sleep 5 - done -} - -if [ ${#setupStep} -eq 0 ]; then - echo "WARN: no setup step found in raspiblitz.info" - setupStep=0 +if [ "${runBehindTor}" = "on" ]; then + OPTIONS+=(NYX "Monitor TOR") fi -if [ ${setupStep} -eq 0 ]; then - - # check data from boostrap - # TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO - if [ "${state}" = "olddata" ]; then - - # old data setup - BACKTITLE="RaspiBlitz - Manual Update" - TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡" - MENU="\n ATTENTION: OLD DATA COULD CONTAIN FUNDS\n" - OPTIONS+=(MANUAL "read how to recover your old funds" \ - DELETE "erase old data, keep blockchain, reboot" ) - HEIGHT=11 - - else - - # show hardware test - /home/admin/05hardwareTest.sh - - # start setup - BACKTITLE="RaspiBlitz - Setup" - TITLE="⚡ Welcome to your RaspiBlitz ⚡" - MENU="\nChoose how you want to setup your RaspiBlitz: \n " - OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \ - LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" ) - HEIGHT=11 - - fi - -elif [ ${setupStep} -lt 100 ]; then - # see function above - if [ ${setupStep} -gt 59 ]; then - waitUntilChainNetworkIsReady - fi - - # continue setup - BACKTITLE="${hostname} / ${network} / ${chain}" - TITLE="⚡ Welcome to your RaspiBlitz ⚡" - MENU="\nThe setup process is not finished yet: \n " - OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz") - HEIGHT=10 - -else - - # see function above - waitUntilChainNetworkIsReady - - # MAIN MENU AFTER SETUP - source ${configFile} - - plus="" - if [ "${runBehindTor}" = "on" ]; then - plus=" / TOR" - fi - if [ ${#dynDomain} -gt 0 ]; then - plus="${plus} / ${dynDomain}" - fi - BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}" - - locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock) - if [ ${locked} -gt 0 ]; then - - if [ "${rtlWebinterface}" = "on" ]; then - # WEBINTERFACE INFO LOCK SCREEN - TITLE="SSH UNLOCK" - MENU="IMPORTANT: Please unlock thru the RTL Webinterface.\nWebinterface --> http://${localip}:3000\nThen TRY AGAIN to get to main menu." - OPTIONS+=(R "TRY AGAIN - check again if unlocked" \ - U "FALLBACK -> Unlock with 'lncli unlock'") - else - # NORMAL LOCK SCREEN - MENU="!!! YOUR WALLET IS LOCKED !!!" - OPTIONS+=(U "Unlock your Lightning Wallet with 'lncli unlock'") - fi - - else - - if [ ${runningRTL} -eq 1 ]; then - TITLE="Webinterface: http://${localip}:3000" - fi - - # Basic Options - OPTIONS+=(INFO "RaspiBlitz Status Screen" \ - FUNDING "Fund your on-chain Wallet" \ - CONNECT "Connect to a Peer" \ - CHANNEL "Open a Channel with Peer" \ - SEND "Pay an Invoice/PaymentRequest" \ - RECEIVE "Create Invoice/PaymentRequest" \ - SERVICES "Activate/Deactivate Services" \ - MOBILE "Connect Mobile Wallet" \ - EXPORT "Macaroons and TLS.cert" \ - NAME "Change Name/Alias of Node" \ - PASSWORD "Change Passwords" \ - CASHOUT "Remove Funds from on-chain Wallet") - - # dont offer lnbalance/lnchannels on testnet - if [ "${chain}" = "main" ]; then - OPTIONS+=(lnbalance "Detailed Wallet Balances" \ - lnchannels "Lightning Channel List") - fi - - # Depending Options - openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length') - if [ ${openChannels} -gt 0 ]; then - OPTIONS+=(CLOSEALL "Close all open Channels") - fi - if [ "${runBehindTor}" = "on" ]; then - OPTIONS+=(NYX "Monitor TOR") - fi - - # final Options - OPTIONS+=(HARDWARE "Run Hardwaretest") - OPTIONS+=(SOFTWARE "Run Softwaretest") - OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update") - OPTIONS+=(OFF "PowerOff RaspiBlitz") - OPTIONS+=(X "Console / Terminal") - - fi - -fi +# final Options +OPTIONS+=(HARDWARE "Run Hardwaretest") +OPTIONS+=(SOFTWARE "Run Softwaretest") +OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update") +OPTIONS+=(OFF "PowerOff RaspiBlitz") +OPTIONS+=(X "Console / Terminal") CHOICE=$(dialog --clear \ --backtitle "$BACKTITLE" \ @@ -400,22 +74,6 @@ case $CHOICE in CLOSE) exit 1; ;; - BITCOIN) - sed -i "s/^network=.*/network=bitcoin/g" ${infoFile} - sed -i "s/^chain=.*/chain=main/g" ${infoFile} - ./10setupBlitz.sh - exit 1; - ;; - LITECOIN) - sed -i "s/^network=.*/network=litecoin/g" ${infoFile} - sed -i "s/^chain=.*/chain=main/g" ${infoFile} - ./10setupBlitz.sh - exit 1; - ;; - CONTINUE) - ./10setupBlitz.sh - exit 1; - ;; INFO) ./00infoBlitz.sh echo "Screen is not updating ... press ENTER to continue." @@ -492,18 +150,6 @@ case $CHOICE in read key ./00mainMenu.sh ;; - TOR) - sudo ./96addTorService.sh - echo "Press ENTER to return to main menu." - read key - ./00mainMenu.sh - ;; - RTL) - sudo ./98installRTL.sh - echo "Press ENTER to return to main menu." - read key - ./00mainMenu.sh - ;; EXPORT) sudo /home/admin/config.scripts/lnd.export.sh echo "Press ENTER to return to main menu." @@ -564,14 +210,6 @@ case $CHOICE in sudo shutdown now exit 0 ;; - MANUAL) - echo "************************************************************************************" - echo "PLEASE go to RaspiBlitz FAQ:" - echo "https://github.com/rootzoll/raspiblitz" - echo "And check: How can I recover my coins from a failing RaspiBlitz?" - echo "************************************************************************************" - exit 0 - ;; DELETE) sudo ./XXcleanHDD.sh sudo shutdown -r now @@ -582,17 +220,4 @@ case $CHOICE in ./00mainMenu.sh exit 0 ;; - X) - lncli -h - echo "OK you now on the command line." - echo "You can return to the main menu with the command:" - echo "raspiblitz" - ;; - R) - ./00mainMenu.sh - ;; - U) # unlock - ./AAunlockLND.sh - ./00mainMenu.sh - ;; esac \ No newline at end of file diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh new file mode 100755 index 0000000..99847b8 --- /dev/null +++ b/home.admin/00raspiblitz.sh @@ -0,0 +1,390 @@ +#!/bin/bash +echo "Starting the main menu ..." + +# CONFIGFILE - configuration of RaspiBlitz +configFile="/mnt/hdd/raspiblitz.conf" + +# INFOFILE - state data from bootstrap +infoFile="/home/admin/raspiblitz.info" + +# check if HDD is connected +hddExists=$(lsblk | grep -c sda1) +if [ ${hddExists} -eq 0 ]; then + + # check if there is maybe a HDD but woth no partitions + noPartition=$(lsblk | grep -c sda) + if [ ${noPartition} -eq 1 ]; then + echo "***********************************************************" + echo "WARNING: HDD HAS NO PARTITIONS" + echo "***********************************************************" + echo "Press ENTER to create a Partition - or CTRL+C to abort" + read key + echo "Creating Partition ..." + sudo parted -s /dev/sda unit s mkpart primary `sudo parted /dev/sda unit s print free | grep 'Free Space' | tail -n 1` + echo "DONE." + sleep 3 + else + echo "***********************************************************" + echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart." + echo "***********************************************************" + exit + fi +fi + +# check data from _bootstrap.sh that was running on device setup +bootstrapInfoExists=$(ls $infoFile | grep -c '.info') +if [ ${bootstrapInfoExists} -eq 0 ]; then + echo "***********************************************************" + echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?" + echo "***********************************************************" + exit +fi + +# load the data from the info file (will get produced on every startup) +source ${infoFile} + +if [ "${state}" = "recovering" ]; then + echo "***********************************************************" + echo "WARNING: bootstrap still updating - close SSH, login later" + echo "To monitor progress --> tail -n1000 -f raspiblitz.log" + echo "***********************************************************" + exit +fi + +# signal that after bootstrap recover user dialog is needed +if [ "${state}" = "recovered" ]; then + echo "System recovered - needs final user settings" + /home/admin/20recoverDialog.sh + exit 1 +fi + +# signal that a reindex was triggered +if [ "${state}" = "reindex" ]; then + echo "Re-Index in progress ... start monitoring:" + /home/admin/config.scripts/network.reindex.sh + exit 1 +fi + +# singal that torrent is in re-download +if [ "${state}" = "retorrent" ]; then + echo "Re-Index in progress ... start monitoring:" + /home/admin/50torrentHDD.sh + sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info + /home/admin/00raspiblitz.sh + exit +fi + +# if pre-sync is running - stop it - before continue +if [ "${state}" = "presync" ]; then + # stopping the pre-sync + echo "" + # analyse if blockchain was detected broken by pre-sync + blockchainBroken=$(sudo tail /mnt/hdd/bitcoin/debug.log | grep -c "Please restart with -reindex or -reindex-chainstate to recover.") + if [ ${blockchainBroken} -eq 1 ]; then + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "Detected corrupted blockchain on pre-sync !" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "Deleting blockchain data ..." + echo "(needs to get downloaded fresh during setup)" + sudo rm -f -r /mnt/hdd/bitcoin + else + echo "********************************************" + echo "Stopping pre-sync ... pls wait (up to 1min)" + echo "********************************************" + sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop + echo "bitcoind called to stop .." + sleep 50 + fi + + # unmount the temporary mount + echo "Unmount HDD .." + sudo umount -l /mnt/hdd + sleep 3 + + # update info file + state=waitsetup + sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile + sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile +fi + +# if state=ready -> setup is done or started +if [ "${state}" = "ready" ]; then + configExists=$(ls ${configFile} | grep -c '.conf') + if [ ${configExists} -eq 1 ]; then + echo "loading config data" + source ${configFile} + else + echo "setup still in progress - setupStep(${setupStep})" + fi +fi + +## default menu settings +# to fit the main menu without scrolling: +# HEIGHT=23 +# CHOICE_HEIGHT=20 +HEIGHT=13 +WIDTH=64 +CHOICE_HEIGHT=6 +BACKTITLE="RaspiBlitz" +TITLE="" +MENU="Choose one of the following options:" +OPTIONS=() + +# check if RTL web interface is installed +runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') + +# get the local network IP to be displayed on the lCD +localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + +# function to use later +waitUntilChainNetworkIsReady() +{ + echo "checking ${network}d - please wait .." + echo "can take longer if device was off or first time" + while : + do + + # check for error on network + sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp + clienterror=`cat error.tmp` + rm error.tmp + + # check for missing blockchain data + minSize=250000000000 + if [ "${network}" = "litecoin" ]; then + minSize=20000000000 + fi + blockchainsize=$(sudo du -shbc /mnt/hdd/${network} | head -n1 | awk '{print $1;}') + if [ ${#blockchainsize} -gt 0 ]; then + if [ ${blockchainsize} -lt ${minSize} ]; then + echo "blockchainsize(${blockchainsize})" + echo "Missing Blockchain Data (<${minSize}) ..." + clienterror="missing blockchain" + sleep 3 + fi + fi + + if [ ${#clienterror} -gt 0 ]; then + + # analyse LOGS for possible reindex + reindex=$(sudo cat /mnt/hdd/${network}/debug.log | grep -c 'Please restart with -reindex or -reindex-chainstate to recover') + if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then + echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options." + sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info + sleep 3 + + dialog --backtitle "RaspiBlitz - Repair Script" --msgbox "Your blockchain data needs to be repaired. +This can be due to power problems or a failing HDD. +Please check the FAQ on RaspiBlitz Github +'My blockchain data is corrupted - what can I do?' +https://github.com/rootzoll/raspiblitz/blob/master/FAQ.md + +The RaspiBlitz will now try to help you on with the repair. +To run a BACKUP of funds & channels first is recommended. +" 13 65 + + clear + # Basic Options + OPTIONS=(TORRENT "Redownload Prepared Torrent (DEFAULT)" \ + COPY "Copy from another Computer (SKILLED)" \ + REINDEX "Resync thru ${network}d (TAKES VERY VERY LONG)" \ + BACKUP "Run Backup LND data first (optional)" + ) + + CHOICE=$(dialog --backtitle "RaspiBlitz - Repair Script" --clear --title "Repair Blockchain Data" --menu "Choose a repair/recovery option:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + + clear + if [ "${CHOICE}" = "TORRENT" ]; then + echo "Starting TORRENT ..." + sudo sed -i "s/^state=.*/state=retorrent/g" /home/admin/raspiblitz.info + /home/admin/50torrentHDD.sh + sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info + /home/admin/00raspiblitz.sh + exit + + elif [ "${CHOICE}" = "COPY" ]; then + echo "Starting COPY ..." + sudo sed -i "s/^state=.*/state=recopy/g" /home/admin/raspiblitz.info + /home/admin/50copyHDD.sh + sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info + /home/admin/00raspiblitz.sh + exit + + elif [ "${CHOICE}" = "REINDEX" ]; then + echo "Starting REINDEX ..." + sudo /home/admin/config.scripts/network.reindex.sh + exit + + elif [ "${CHOICE}" = "BACKUP" ]; then + sudo /home/admin/config.scripts/lnd.rescue.sh backup + echo "PRESS ENTER to return to menu." + read key + /home/admin/00raspiblitz.sh + exit + + else + echo "CANCEL" + exit + fi + + else + echo "${network} error: ${clienterror}" + fi + + # normal info + boxwidth=40 + l1="Waiting for ${network}d to get ready.\n" + l2="---> ${clienterror/error*:/}\n" + l3="Can take longer if device was off." + uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')" + # after 2 min show complete long string (full detail) + if [ ${uptimeSeconds} -gt 120 ]; then + boxwidth=80 + l2="${clienterror}\n" + l3="CTRL+C => terminal" + fi + dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth} + else + locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) + if [ ${locked} -gt 0 ]; then + /home/admin/AAunlockLND.sh + echo "please wait ... update to next screen can be slow" + fi + lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) + if [ ${lndSynced} -eq 0 ]; then + /home/admin/80scanLND.sh + else + # everything is ready - return from loop + return + fi + fi + sleep 5 + done +} + +if [ ${#setupStep} -eq 0 ]; then + echo "WARN: no setup step found in raspiblitz.info" + setupStep=0 +fi +if [ ${setupStep} -eq 0 ]; then + + # check data from boostrap + # TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO + if [ "${state}" = "olddata" ]; then + + # old data setup + BACKTITLE="RaspiBlitz - Manual Update" + TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡" + MENU="\n ATTENTION: OLD DATA COULD CONTAIN FUNDS\n" + OPTIONS+=(MANUAL "read how to recover your old funds" \ + DELETE "erase old data, keep blockchain, reboot" ) + HEIGHT=11 + + else + + # show hardware test + /home/admin/05hardwareTest.sh + + # start setup + BACKTITLE="RaspiBlitz - Setup" + TITLE="⚡ Welcome to your RaspiBlitz ⚡" + MENU="\nChoose how you want to setup your RaspiBlitz: \n " + OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \ + LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" ) + HEIGHT=11 + + fi + +elif [ ${setupStep} -lt 100 ]; then + + # see function above + if [ ${setupStep} -gt 59 ]; then + waitUntilChainNetworkIsReady + fi + + # continue setup + BACKTITLE="${hostname} / ${network} / ${chain}" + TITLE="⚡ Welcome to your RaspiBlitz ⚡" + MENU="\nThe setup process is not finished yet: \n " + OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz") + HEIGHT=10 + +else + /home/admin/00mainMenu.sh + exit 0 +fi + +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +clear +case $CHOICE in + CLOSE) + exit 1; + ;; + BITCOIN) + sed -i "s/^network=.*/network=bitcoin/g" ${infoFile} + sed -i "s/^chain=.*/chain=main/g" ${infoFile} + /home/admin/10setupBlitz.sh + exit 1; + ;; + LITECOIN) + sed -i "s/^network=.*/network=litecoin/g" ${infoFile} + sed -i "s/^chain=.*/chain=main/g" ${infoFile} + /home/admin/10setupBlitz.sh + exit 1; + ;; + CONTINUE) + /home/admin/10setupBlitz.sh + exit 1; + ;; + OFF) + echo "" + echo "LCD turns white when shutdown complete." + echo "Then wait 5 seconds and disconnect power." + echo "-----------------------------------------------" + echo "stop lnd - please wait .." + sudo systemctl stop lnd + echo "stop ${network}d (1) - please wait .." + sudo -u bitcoin ${network}-cli stop + sleep 10 + echo "stop ${network}d (2) - please wait .." + sudo systemctl stop ${network}d + sleep 3 + sync + echo "starting shutdown ..." + sudo shutdown now + exit 0 + ;; + MANUAL) + echo "************************************************************************************" + echo "PLEASE go to RaspiBlitz FAQ:" + echo "https://github.com/rootzoll/raspiblitz" + echo "And check: How can I recover my coins from a failing RaspiBlitz?" + echo "************************************************************************************" + exit 0 + ;; + DELETE) + sudo /home/admin/XXcleanHDD.sh + sudo shutdown -r now + exit 0 + ;; + X) + lncli -h + echo "OK you now on the command line." + echo "You can return to the main menu with the command:" + echo "raspiblitz" + ;; + R) + /home/admin/00raspiblitz.sh + ;; + U) # unlock + /home/admin/AAunlockLND.sh + /home/admin/00raspiblitz.sh + ;; +esac diff --git a/home.admin/50downloadHDD.sh b/home.admin/50downloadHDD.sh index ce0cc5b..43f008b 100755 --- a/home.admin/50downloadHDD.sh +++ b/home.admin/50downloadHDD.sh @@ -143,7 +143,7 @@ if [ ${finalSize} -lt ${targetSize} ]; then case $response in 1) sudo rm -rf /mnt/hdd/download ;; esac - ./00mainMenu.sh + ./00raspiblitz.sh exit 1; else diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 8395874..aa870ad 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -361,7 +361,7 @@ if [ ${torrentError} -gt 0 ]; then case $response in 1) sudo rm -rf ${targetDir}; sudo rm -rf ${sessionDir} ;; esac - ./00mainMenu.sh + ./00raspiblitz.sh exit 1; fi diff --git a/home.admin/_commands.sh b/home.admin/_commands.sh index b1d54bd..80cb51d 100644 --- a/home.admin/_commands.sh +++ b/home.admin/_commands.sh @@ -6,5 +6,5 @@ # calls the the raspiblitz mainmenu function raspiblitz() { cd /home/admin - ./00mainMenu.sh + ./00raspiblitz.sh } \ No newline at end of file From 6e34ef7f1c601729e9722d28b28c0d0cef10ac0c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 19:00:12 +0100 Subject: [PATCH 109/162] debug --- home.admin/00raspiblitz.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 99847b8..a273c31 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -262,6 +262,9 @@ To run a BACKUP of funds & channels first is recommended. done } +echo "B" +read key + if [ ${#setupStep} -eq 0 ]; then echo "WARN: no setup step found in raspiblitz.info" setupStep=0 @@ -310,10 +313,16 @@ elif [ ${setupStep} -lt 100 ]; then HEIGHT=10 else + + waitUntilChainNetworkIsReady + /home/admin/00mainMenu.sh exit 0 fi +echo "A" +read key + CHOICE=$(dialog --clear \ --backtitle "$BACKTITLE" \ --title "$TITLE" \ From 7873a84b3aaabbcd31dacdd1bc6c20c7aa140945 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 19:02:10 +0100 Subject: [PATCH 110/162] debug --- home.admin/00mainMenu.sh | 2 +- home.admin/00raspiblitz.sh | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 7ab116f..3e7a0c1 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -69,7 +69,7 @@ CHOICE=$(dialog --clear \ "${OPTIONS[@]}" \ 2>&1 >/dev/tty) -clear +#clear case $CHOICE in CLOSE) exit 1; diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index a273c31..c26f520 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -262,9 +262,6 @@ To run a BACKUP of funds & channels first is recommended. done } -echo "B" -read key - if [ ${#setupStep} -eq 0 ]; then echo "WARN: no setup step found in raspiblitz.info" setupStep=0 @@ -314,14 +311,12 @@ elif [ ${setupStep} -lt 100 ]; then else + # when all is setup - forward to main menu waitUntilChainNetworkIsReady - /home/admin/00mainMenu.sh exit 0 -fi -echo "A" -read key +fi CHOICE=$(dialog --clear \ --backtitle "$BACKTITLE" \ From c4e7f9e5d08418a60a73805551090b7c7861477e Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 19:05:23 +0100 Subject: [PATCH 111/162] fix if errors --- home.admin/00mainMenu.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 3e7a0c1..0f58265 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -20,7 +20,8 @@ if [ ${#dynDomain} -gt 0 ]; then plus="${plus} / ${dynDomain}" fi BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}" -if [ ${runningRTL} -eq 1 ]; then + +if [ "${rtlWebinterface}" == "on" ]; then TITLE="Webinterface: http://${localip}:3000" fi @@ -47,10 +48,10 @@ fi # Depending Options openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length') -if [ ${openChannels} -gt 0 ]; then +if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then OPTIONS+=(CLOSEALL "Close all open Channels") fi -if [ "${runBehindTor}" = "on" ]; then +if [ "${runBehindTor}" == "on" ]; then OPTIONS+=(NYX "Monitor TOR") fi From 71be71c72136cdd71cc6a74ba6b1514748e4a9dd Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 19:07:13 +0100 Subject: [PATCH 112/162] Added Basic Menu info --- home.admin/00mainMenu.sh | 9 ++++++++- home.admin/00raspiblitz.sh | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 0f58265..dc34c90 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -11,7 +11,14 @@ infoFile="/home/admin/raspiblitz.info" source ${infoFile} source ${configFile} -# Backtitle Info +# BASIC MENU INFO +HEIGHT=13 +WIDTH=64 +CHOICE_HEIGHT=6 +BACKTITLE="RaspiBlitz" +TITLE="" +MENU="Choose one of the following options:" +OPTIONS=() plus="" if [ "${runBehindTor}" = "on" ]; then plus=" / TOR" diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index c26f520..8442104 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -120,8 +120,6 @@ fi ## default menu settings # to fit the main menu without scrolling: -# HEIGHT=23 -# CHOICE_HEIGHT=20 HEIGHT=13 WIDTH=64 CHOICE_HEIGHT=6 From 9e6914dfa5c2d029ac64c158097f121eddb20552 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 19:29:47 +0100 Subject: [PATCH 113/162] #516 format HDD just on confirmation --- home.admin/30initHDD.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/home.admin/30initHDD.sh b/home.admin/30initHDD.sh index ac7dc9d..9b0bbb0 100755 --- a/home.admin/30initHDD.sh +++ b/home.admin/30initHDD.sh @@ -70,6 +70,21 @@ if [ ${existsHDD} -eq 1 ]; then echo "FAIL - HDD is mounted" echo "If you really want to reinit the HDD, then unmount the HDD first and try again" else + echo "" + dialog --title "Format HDD" --yes-button "Yes" --no-button "Cancel" --yesno "RaspiBlitz detected a Hard Disk Drive (HDD). +It will get formatted to EXT4 to be usefull. +This will DELETE ALL FORMER DATA on the HDD. + +Is it OK to delete HDD for fresh RaspiBlitz? + " 10 48 + if [ $? -eq 1 ]; then + dialog --title "Replace HDD" --msgbox "OK. RaspiBlitz will shutdown now. +Please disconnect Power then. +Backup HDD data or connect another one. +Then Power up again." 8 39 + sudo shutdown now + exit 1 + fi echo "" echo "*** Formatting the HDD ***" echo "WARNING ALL DATA ON HDD WILL GET DELETED - CAN TAKE SOME TIME" From b0ca3606f84af69252515afc07c335825eb100ed Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:25:27 +0100 Subject: [PATCH 114/162] Start refactor 80scanLND --- home.admin/80scanLND.old.sh | 101 +++++++++++++++++ home.admin/config.scripts/blitz.statusscan.sh | 105 ++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100755 home.admin/80scanLND.old.sh create mode 100644 home.admin/config.scripts/blitz.statusscan.sh diff --git a/home.admin/80scanLND.old.sh b/home.admin/80scanLND.old.sh new file mode 100755 index 0000000..75e4bc1 --- /dev/null +++ b/home.admin/80scanLND.old.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +source /home/admin/raspiblitz.info +source /mnt/hdd/raspiblitz.conf + +### USER PI AUTOSTART (LCD Display) +localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + +# parse the actual scanned height progress from LND logs +item=0 +blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo) +chain="$(echo "${blockchaininfo}" | jq -r '.chain')" + +## TRY to get the actual progress height of scanning + +# 1) First try the "Rescanned through block" - it seems to happen if it restarts +item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Rescanned through block" | tail -n1 | cut -d ']' -f2 | cut -d '(' -f2 | tr -dc '0-9') +action="Rescanning" + +# 2) Second try the "Caught up to height" - thats the usual on first scan start +if [ ${#item} -eq 0 ]; then + item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Caught up to height" | tail -n1 | cut -d ']' -f2 | tr -dc '0-9') + action="Catching-Up" +fi + +# 3) Third try the "LNWL: Filtering block" - thats the usual on later starts +if [ ${#item} -eq 0 ]; then + item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "LNWL: Filtering block" | tail -n1 | cut -d ' ' -f7 | tr -dc '0-9') + action="Filtering" +fi + +# if no progress info +online=1 +if [ ${#item} -eq 0 ]; then + item="?" + + # check if offline + online=$(ping 1.0.0.1 -c 1 -W 2 | grep -c '1 received') + if [ ${online} -eq 0 ]; then + # re-test with other server + online=$(ping 8.8.8.8 -c 1 -W 2 | grep -c '1 received') + fi + if [ ${online} -eq 0 ]; then + # re-test with other server + online=$(ping 208.67.222.222 -c 1 -W 2 | grep -c '1 received') + fi + +fi + +# get total number of blocks +total=$(echo "${blockchaininfo}" | jq -r '.blocks') +# put scanstate +scanstate="${item}/${total}" + +# get blockchain sync progress +progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" +#progress=$(echo "${progress}*100" | bc) +progress=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}') + +# check if blockchain is still syncing +heigh=6 +width=44 +isInitialChainSync=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c) +isWaitingBlockchain=$( sudo -u bitcoin tail -n 2 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Waiting for chain backend to finish sync" -c ) +if [ ${isWaitingBlockchain} -gt 0 ]; then + isInitialChainSync=1 +fi +if [ ${online} -eq 0 ]; then + heigh=7 + width=44 + infoStr=$(echo " Waiting INTERNET CONNECTION\n RaspiBlitz cannot ping 1.0.0.1\n Local IP is ${localip}\n Please check cables and router.") +elif [ ${isInitialChainSync} -gt 0 ]; then + heigh=7 + infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress} \n Please wait - this can take some time.\n ssh admin@${localip}\n Password A" + if [ "$USER" = "admin" ]; then + heigh=6 + width=53 + infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress} %\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") + fi +else + heigh=7 + # check if wallet has any UTXO + # reason see: https://github.com/lightningnetwork/lnd/issues/2326 + txlines=$(sudo -u bitcoin lncli listchaintxns 2>/dev/null | wc -l) + # has just 4 lines if empty + if [ ${txlines} -eq 4 ]; then + infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n re-rescan every start until funding\n ssh admin@${localip}\n Password A") + else + infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A") + if [ "$USER" = "admin" ]; then + heigh=6 + width=53 + infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") + fi + fi +fi + +# display progress to user +sleep 3 +temp=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc) +dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname}) CPU: ${temp}°C" --infobox "${infoStr}" ${heigh} ${width} \ No newline at end of file diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh new file mode 100644 index 0000000..d99fefb --- /dev/null +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +source /home/admin/raspiblitz.info +source /mnt/hdd/raspiblitz.conf + +# command info +if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "# script to scan the state of the system after setup" + exit 1 +fi + +# measure time of scan +startTime=$(date +%s) + +# localIP +localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') +echo "localIP='${localip}'" + +# is bitcoind running +bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running) +echo "bitcoinActive=${bitcoinRunning}" + +if [ ${bitcoinRunning} -eq 1 ]; then + + # get blockchain info + blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/home/bitcoin/.${network}/.bitcoind.error) + + # check if error on request + bitcoinError=$(sudo -u bitcoin cat /home/bitcoin/.${network}/.bitcoind.error | tr "'" '"' | tr '"' '\"' ) + sudo -u bitcoin rm /home/bitcoin/.${network}/.bitcoind.error + if [ ${#bitcoinError} -gt 0 ]; + echo "bitcoinError='${bitcoinError}'" + else + + ############################## + # Get data from blockchaininfo + ############################## + + # get total number of blocks + total=$(echo ${blockchaininfo} | jq -r '.blocks') + echo "blockchainHeight=${total}" + + # is initial sync of blockchain + initialSync=$(echo ${blockchaininfo} | jq -r '.initialblockdownload' | grep -c 'true') + echo "initialSync=${initialSync}" + + # get blockchain sync progress + syncProgress="$(echo ${blockchaininfo} | jq -r '.verificationprogress')" + syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}') + echo "syncProgress=${syncProgress}" + + fi +fi + +# is LND running +lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running) + +# TODO: check how long running ... try to find out if problem on starting + +echo "lndActive=${lndRunning}" + +if [ ${lndRunning} -eq 1 ]; then + + # get LND info + lndinfo=$(sudo -u bitcoin lncli getinfo 2>/home/bitcoin/.lnd/.lnd.error) + + # check if error on request + lndError=$(sudo -u bitcoin cat /home/bitcoin/.lnd/.lnd.error | tr "'" '"' | tr '"' '\"' ) + sudo -u bitcoin rm /home/bitcoin/.lnd/.lnd.error + if [ ${#lndError} -gt 0 ]; + echo "lndError='${lndError}'" + else + + # synced to chain + syncedToChain=$(echo ${lndinfo} | jq -r '.synced_to_chain' | grep -c 'true') + echo "syncedToChain=${syncedToChain}" + + # lnd scan progress + lndTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp') + echo "lndTimestamp=${lndTimestamp}" + lndDate=$(date -d @${lndTimestamp}) + echo "lndDate=${lndDate}" + + # calculate LND scan progress by seconds since Genesisblock + genesisTimestamp=1230940800 + nowTimestamp=$(date +%s) + totalSeconds=$(echo "${nowTimestamp}-${genesisTimestamp}" | bc) + echo "# totalSeconds($totalSeconds)" + scannedSeconds=$(echo "${lndTimestamp}-${genesisTimestamp}" | bc) + echo "# scannedSeconds($scannedSeconds)" + scanProgress=$(echo "scale=2; $scannedSeconds*100/$totalSeconds" | bc) + echo "scanProgress=${scanProgress}" + + fi + +fi + +# check if online if problem with other stuff + +# info on scan run time +endTime=$(date +%s) +runTime=$(echo "${endTime}-${startTime}" | bc) +echo "scantime=${runTime}" + + From ac20b2af822df0b9a19fd327b30a936ec91a280a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:26:37 +0100 Subject: [PATCH 115/162] fix else --- home.admin/config.scripts/blitz.statusscan.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index d99fefb..41047d3 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -28,7 +28,7 @@ if [ ${bitcoinRunning} -eq 1 ]; then # check if error on request bitcoinError=$(sudo -u bitcoin cat /home/bitcoin/.${network}/.bitcoind.error | tr "'" '"' | tr '"' '\"' ) sudo -u bitcoin rm /home/bitcoin/.${network}/.bitcoind.error - if [ ${#bitcoinError} -gt 0 ]; + if [ ${#bitcoinError} -gt 0 ]; then echo "bitcoinError='${bitcoinError}'" else @@ -67,7 +67,7 @@ if [ ${lndRunning} -eq 1 ]; then # check if error on request lndError=$(sudo -u bitcoin cat /home/bitcoin/.lnd/.lnd.error | tr "'" '"' | tr '"' '\"' ) sudo -u bitcoin rm /home/bitcoin/.lnd/.lnd.error - if [ ${#lndError} -gt 0 ]; + if [ ${#lndError} -gt 0 ]; then echo "lndError='${lndError}'" else From 9323227626fed3b563cf35697fc4dfd6ed5d369c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:31:52 +0100 Subject: [PATCH 116/162] fix permission errors --- home.admin/config.scripts/blitz.statusscan.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 41047d3..3b74c7e 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -12,6 +12,10 @@ fi # measure time of scan startTime=$(date +%s) +# macke sure temp folder on HDD is available and fro all usable +sudo mkdir /mnt/hdd/temp 2>/dev/null +sudo chmod 777 -R /mnt/hdd/temp 2>/dev/null + # localIP localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') echo "localIP='${localip}'" @@ -23,11 +27,11 @@ echo "bitcoinActive=${bitcoinRunning}" if [ ${bitcoinRunning} -eq 1 ]; then # get blockchain info - blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/home/bitcoin/.${network}/.bitcoind.error) + blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/mnt/hdd/temp/.bitcoind.error) # check if error on request - bitcoinError=$(sudo -u bitcoin cat /home/bitcoin/.${network}/.bitcoind.error | tr "'" '"' | tr '"' '\"' ) - sudo -u bitcoin rm /home/bitcoin/.${network}/.bitcoind.error + bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null | tr "'" '"' | tr '"' '\"' ) + rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null if [ ${#bitcoinError} -gt 0 ]; then echo "bitcoinError='${bitcoinError}'" else @@ -62,11 +66,11 @@ echo "lndActive=${lndRunning}" if [ ${lndRunning} -eq 1 ]; then # get LND info - lndinfo=$(sudo -u bitcoin lncli getinfo 2>/home/bitcoin/.lnd/.lnd.error) + lndinfo=$(sudo -u bitcoin lncli getinfo 2>/mnt/hdd/temp/.lnd.error) # check if error on request - lndError=$(sudo -u bitcoin cat /home/bitcoin/.lnd/.lnd.error | tr "'" '"' | tr '"' '\"' ) - sudo -u bitcoin rm /home/bitcoin/.lnd/.lnd.error + lndError=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null | tr "'" '"' | tr '"' '\"' ) + rm /mnt/hdd/temp/.lnd.error 2>/dev/null if [ ${#lndError} -gt 0 ]; then echo "lndError='${lndError}'" else From fb9c35dbbbc328935db5a9383d65d738673555bb Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:35:45 +0100 Subject: [PATCH 117/162] syncprocess without % --- home.admin/config.scripts/blitz.statusscan.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 3b74c7e..4482a71 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -50,7 +50,7 @@ if [ ${bitcoinRunning} -eq 1 ]; then # get blockchain sync progress syncProgress="$(echo ${blockchaininfo} | jq -r '.verificationprogress')" - syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}') + syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%", 100 * $1)}') echo "syncProgress=${syncProgress}" fi @@ -80,18 +80,16 @@ if [ ${lndRunning} -eq 1 ]; then echo "syncedToChain=${syncedToChain}" # lnd scan progress - lndTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp') - echo "lndTimestamp=${lndTimestamp}" - lndDate=$(date -d @${lndTimestamp}) - echo "lndDate=${lndDate}" + scanTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp') + echo "scanTimestamp=${scanTimestamp}" + scanDate=$(date -d @${scanTimestamp}) + echo "scanDate=${scanDate}" # calculate LND scan progress by seconds since Genesisblock genesisTimestamp=1230940800 nowTimestamp=$(date +%s) totalSeconds=$(echo "${nowTimestamp}-${genesisTimestamp}" | bc) - echo "# totalSeconds($totalSeconds)" - scannedSeconds=$(echo "${lndTimestamp}-${genesisTimestamp}" | bc) - echo "# scannedSeconds($scannedSeconds)" + scannedSeconds=$(echo "${scanTimestamp}-${genesisTimestamp}" | bc) scanProgress=$(echo "scale=2; $scannedSeconds*100/$totalSeconds" | bc) echo "scanProgress=${scanProgress}" @@ -104,6 +102,6 @@ fi # info on scan run time endTime=$(date +%s) runTime=$(echo "${endTime}-${startTime}" | bc) -echo "scantime=${runTime}" +echo "scriptRuntime=${runTime}" From 0f6484aa28cbed45d389ae9d22a2339c4e6e7d02 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:39:04 +0100 Subject: [PATCH 118/162] remove % from progress --- home.admin/config.scripts/blitz.statusscan.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 4482a71..08faab6 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -50,7 +50,7 @@ if [ ${bitcoinRunning} -eq 1 ]; then # get blockchain sync progress syncProgress="$(echo ${blockchaininfo} | jq -r '.verificationprogress')" - syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%", 100 * $1)}') + syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}' | tr '%' '' | tr -s " ") echo "syncProgress=${syncProgress}" fi From f0137407be732d310e4c3294a5b33c6ee6846106 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:39:49 +0100 Subject: [PATCH 119/162] removing % from progress --- home.admin/config.scripts/blitz.statusscan.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 08faab6..2fc889e 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -50,7 +50,7 @@ if [ ${bitcoinRunning} -eq 1 ]; then # get blockchain sync progress syncProgress="$(echo ${blockchaininfo} | jq -r '.verificationprogress')" - syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}' | tr '%' '' | tr -s " ") + syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}' | tr '%' ' ' | tr -s " ") echo "syncProgress=${syncProgress}" fi From 66bac72650f2ca627f1808390b450ee5a02d5bf6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:48:22 +0100 Subject: [PATCH 120/162] display scan --- home.admin/80scanLND.sh | 96 ++----------------- home.admin/config.scripts/blitz.statusscan.sh | 2 +- 2 files changed, 7 insertions(+), 91 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 75e4bc1..4eef540 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -3,99 +3,15 @@ source /home/admin/raspiblitz.info source /mnt/hdd/raspiblitz.conf -### USER PI AUTOSTART (LCD Display) -localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') +source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) -# parse the actual scanned height progress from LND logs -item=0 -blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo) -chain="$(echo "${blockchaininfo}" | jq -r '.chain')" - -## TRY to get the actual progress height of scanning - -# 1) First try the "Rescanned through block" - it seems to happen if it restarts -item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Rescanned through block" | tail -n1 | cut -d ']' -f2 | cut -d '(' -f2 | tr -dc '0-9') -action="Rescanning" - -# 2) Second try the "Caught up to height" - thats the usual on first scan start -if [ ${#item} -eq 0 ]; then - item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Caught up to height" | tail -n1 | cut -d ']' -f2 | tr -dc '0-9') - action="Catching-Up" -fi - -# 3) Third try the "LNWL: Filtering block" - thats the usual on later starts -if [ ${#item} -eq 0 ]; then - item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "LNWL: Filtering block" | tail -n1 | cut -d ' ' -f7 | tr -dc '0-9') - action="Filtering" -fi - -# if no progress info -online=1 -if [ ${#item} -eq 0 ]; then - item="?" - - # check if offline - online=$(ping 1.0.0.1 -c 1 -W 2 | grep -c '1 received') - if [ ${online} -eq 0 ]; then - # re-test with other server - online=$(ping 8.8.8.8 -c 1 -W 2 | grep -c '1 received') - fi - if [ ${online} -eq 0 ]; then - # re-test with other server - online=$(ping 208.67.222.222 -c 1 -W 2 | grep -c '1 received') - fi - -fi - -# get total number of blocks -total=$(echo "${blockchaininfo}" | jq -r '.blocks') -# put scanstate -scanstate="${item}/${total}" - -# get blockchain sync progress -progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" -#progress=$(echo "${progress}*100" | bc) -progress=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}') - -# check if blockchain is still syncing -heigh=6 +height=6 width=44 -isInitialChainSync=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c) -isWaitingBlockchain=$( sudo -u bitcoin tail -n 2 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Waiting for chain backend to finish sync" -c ) -if [ ${isWaitingBlockchain} -gt 0 ]; then - isInitialChainSync=1 -fi -if [ ${online} -eq 0 ]; then - heigh=7 - width=44 - infoStr=$(echo " Waiting INTERNET CONNECTION\n RaspiBlitz cannot ping 1.0.0.1\n Local IP is ${localip}\n Please check cables and router.") -elif [ ${isInitialChainSync} -gt 0 ]; then - heigh=7 - infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress} \n Please wait - this can take some time.\n ssh admin@${localip}\n Password A" - if [ "$USER" = "admin" ]; then - heigh=6 - width=53 - infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress} %\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") - fi -else - heigh=7 - # check if wallet has any UTXO - # reason see: https://github.com/lightningnetwork/lnd/issues/2326 - txlines=$(sudo -u bitcoin lncli listchaintxns 2>/dev/null | wc -l) - # has just 4 lines if empty - if [ ${txlines} -eq 4 ]; then - infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n re-rescan every start until funding\n ssh admin@${localip}\n Password A") - else - infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A") - if [ "$USER" = "admin" ]; then - heigh=6 - width=53 - infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") - fi - fi -fi + +#infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP}\n Password A" +infoStr=" Lightning Scanning Blockchain\n Progress: ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP}\n Password A" # display progress to user sleep 3 temp=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc) -dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname}) CPU: ${temp}°C" --infobox "${infoStr}" ${heigh} ${width} \ No newline at end of file +dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname}) CPU: ${temp}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 2fc889e..0d1ce6f 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -83,7 +83,7 @@ if [ ${lndRunning} -eq 1 ]; then scanTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp') echo "scanTimestamp=${scanTimestamp}" scanDate=$(date -d @${scanTimestamp}) - echo "scanDate=${scanDate}" + echo "scanDate='${scanDate}'" # calculate LND scan progress by seconds since Genesisblock genesisTimestamp=1230940800 From 2d0a6f5db677265d24773876932ac5a3d171bfba Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 21:53:22 +0100 Subject: [PATCH 121/162] Progress screen --- home.admin/80scanLND.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 4eef540..f35afbf 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -6,12 +6,11 @@ source /mnt/hdd/raspiblitz.conf source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) height=6 -width=44 +width=52 -#infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP}\n Password A" -infoStr=" Lightning Scanning Blockchain\n Progress: ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP}\n Password A" +#infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP} -> Password A" +infoStr=" Node is Syncing\n Blockchain Progress : ${scanProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP} ->Password A" # display progress to user -sleep 3 temp=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc) dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname}) CPU: ${temp}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file From c1b1ffa567b28b6c4bf47abf615d9e8bec34e04b Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:00:49 +0100 Subject: [PATCH 122/162] layout progress --- home.admin/80scanLND.sh | 15 +++++++++++---- home.admin/config.scripts/blitz.statusscan.sh | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index f35afbf..cca5ced 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -1,16 +1,23 @@ #!/bin/bash +source /home/admin/_version.info source /home/admin/raspiblitz.info source /mnt/hdd/raspiblitz.conf source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) -height=6 +height=8 width=52 #infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP} -> Password A" -infoStr=" Node is Syncing\n Blockchain Progress : ${scanProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP} ->Password A" +title="Node is Syncing" +if [ ${#syncProgress} -lt 6 ]; then + syncProgress=" ${syncProgress}" +fi +if [ ${#scanProgress} -lt 6 ]; then + scanProgress=" ${scanProgress}" +fi +infoStr=" Blockchain Progress : ${syncProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP} ->Password A" # display progress to user -temp=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc) -dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname}) CPU: ${temp}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file +dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} (${hostname}) / ${network} / ${chain} / CPU: ${tempCelsius}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 0d1ce6f..0f88a3b 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -20,6 +20,10 @@ sudo chmod 777 -R /mnt/hdd/temp 2>/dev/null localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') echo "localIP='${localip}'" +# temp +tempC=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc) +echo "tempCelsius='${tempC}'" + # is bitcoind running bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running) echo "bitcoinActive=${bitcoinRunning}" From 83af0ce5226514ed90346c22f564f6533a434faf Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:03:01 +0100 Subject: [PATCH 123/162] LCD layout --- home.admin/80scanLND.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index cca5ced..17b574f 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -6,8 +6,8 @@ source /mnt/hdd/raspiblitz.conf source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) -height=8 -width=52 +height=6 +width=44 #infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP} -> Password A" title="Node is Syncing" @@ -20,4 +20,4 @@ fi infoStr=" Blockchain Progress : ${syncProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP} ->Password A" # display progress to user -dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} (${hostname}) / ${network} / ${chain} / CPU: ${tempCelsius}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file +dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file From ec4ee895ed45aecc987a2feeafc17bba0af760a9 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:07:59 +0100 Subject: [PATCH 124/162] admin detail --- home.admin/80scanLND.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 17b574f..1be7061 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -7,7 +7,7 @@ source /mnt/hdd/raspiblitz.conf source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) height=6 -width=44 +width=42 #infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP} -> Password A" title="Node is Syncing" @@ -17,7 +17,12 @@ fi if [ ${#scanProgress} -lt 6 ]; then scanProgress=" ${scanProgress}" fi -infoStr=" Blockchain Progress : ${syncProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time\n ssh admin@${localIP} ->Password A" + +infoStr=" Blockchain Progress : ${syncProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time" +adminStr="ssh admin@${localIP} ->Password A" +if [ "$USER" == "admin" ]; then + adminStr="Use CTRL+c to EXIT to Terminal" +fi # display progress to user -dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}" ${height} ${width} \ No newline at end of file +dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n${adminStr}" ${height} ${width} \ No newline at end of file From c28e8ac653a6a652bc70f83946b106af0d30c308 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:08:55 +0100 Subject: [PATCH 125/162] UI layout --- home.admin/80scanLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 1be7061..101df28 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -25,4 +25,4 @@ if [ "$USER" == "admin" ]; then fi # display progress to user -dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n${adminStr}" ${height} ${width} \ No newline at end of file +dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width} \ No newline at end of file From f3c176b0d3c8df30d2266eb7a83aafab51122c9c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:10:35 +0100 Subject: [PATCH 126/162] UI Layout --- home.admin/80scanLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 101df28..9ae1e8f 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -18,7 +18,7 @@ if [ ${#scanProgress} -lt 6 ]; then scanProgress=" ${scanProgress}" fi -infoStr=" Blockchain Progress : ${syncProgress}%\n Lightning Progress : ${scanProgress}%\n Please wait - this can take some time" +infoStr=" Blockchain Progress : ${syncProgress} %\n Lightning Progress : ${scanProgress} %\n Please wait - this can take some time" adminStr="ssh admin@${localIP} ->Password A" if [ "$USER" == "admin" ]; then adminStr="Use CTRL+c to EXIT to Terminal" From dc975a2f4af51b16375848ff502c0e4089cda322 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:23:06 +0100 Subject: [PATCH 127/162] display bitcoin lnd error --- home.admin/80scanLND.sh | 66 ++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 9ae1e8f..d31f68a 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -6,23 +6,61 @@ source /mnt/hdd/raspiblitz.conf source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) -height=6 -width=42 - -#infoStr=" Waiting for Blockchain Sync\n Progress: ${syncProgress}% \n Please wait - this can take some time.\n ssh admin@${localIP} -> Password A" -title="Node is Syncing" -if [ ${#syncProgress} -lt 6 ]; then - syncProgress=" ${syncProgress}" -fi -if [ ${#scanProgress} -lt 6 ]; then - scanProgress=" ${scanProgress}" -fi - -infoStr=" Blockchain Progress : ${syncProgress} %\n Lightning Progress : ${scanProgress} %\n Please wait - this can take some time" adminStr="ssh admin@${localIP} ->Password A" if [ "$USER" == "admin" ]; then adminStr="Use CTRL+c to EXIT to Terminal" fi -# display progress to user +if [ ${bitcoinActive} -eq 0 ]; then + + #################### + # On Bitcoin Error + #################### + + height=6 + width=42 + title="Blockchain Error" + infoStr="The ${network}d service is not running." + if [ "$USER" == "admin" ]; then + infoStr="${infoStr}\n${bitcoinError}" + fi + +elif [ ${lndActive} -eq 0 ]; then + + #################### + # On LND Error + #################### + + height=6 + width=42 + title="Lightning Error" + infoStr="The lnd service is not running." + if [ "$USER" == "admin" ]; then + infoStr="${infoStr}\n${lndError}" + fi + +else + + #################### + # Sync Progress + #################### + + # basic dialog info + height=6 + width=42 + title="Node is Syncing" + + # format progress values + if [ ${#syncProgress} -lt 6 ]; then + syncProgress=" ${syncProgress}" + fi + if [ ${#scanProgress} -lt 6 ]; then + scanProgress=" ${scanProgress}" + fi + + infoStr=" Blockchain Progress : ${syncProgress} %\n Lightning Progress : ${scanProgress} %\n Please wait - this can take some time" + +fi + +# display info to user dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width} \ No newline at end of file From 995000bab6360f9dce18d6662cb142f8cb412196 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:24:01 +0100 Subject: [PATCH 128/162] runtime script --- home.admin/80scanLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index d31f68a..8a9b9df 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -48,7 +48,7 @@ else # basic dialog info height=6 width=42 - title="Node is Syncing" + title="Node is Syncing (${scriptRuntime})" # format progress values if [ ${#syncProgress} -lt 6 ]; then From 1625dc777f9fdad7849cf0d2aecf0c48af6ed494 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:45:57 +0100 Subject: [PATCH 129/162] make lower 50MB mem warning --- home.admin/00infoBlitz.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index 5bd996f..0ed607a 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -58,7 +58,7 @@ tempF=$(((cpu/1000) * (9/5) + 32)) ram_avail=$(free -m | grep Mem | awk '{ print $7 }') ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')") -if [ ${ram_avail} -lt 100 ]; then +if [ ${ram_avail} -lt 50 ]; then color_ram="${color_red}\e[7m" else color_ram=${color_green} From d7d3f92430c8608840e8130622f90061bdefc727 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 22:58:59 +0100 Subject: [PATCH 130/162] test error login --- home.admin/80scanLND.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 8a9b9df..e2c9b7f 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -19,8 +19,8 @@ if [ ${bitcoinActive} -eq 0 ]; then height=6 width=42 - title="Blockchain Error" - infoStr="The ${network}d service is not running." + title="Blockchain Warning" + infoStr=" The ${network}d service is not running.\n Login for more details." if [ "$USER" == "admin" ]; then infoStr="${infoStr}\n${bitcoinError}" fi @@ -31,12 +31,19 @@ elif [ ${lndActive} -eq 0 ]; then # On LND Error #################### - height=6 + height=5 width=42 - title="Lightning Error" - infoStr="The lnd service is not running." + title="Lightning Warning" + infoStr=" The lnd service is not running.\n Login for more details." if [ "$USER" == "admin" ]; then - infoStr="${infoStr}\n${lndError}" + clear + echo "*********************************" + echo "* The lnd service is not running." + echo "*********************************" + echo ${lndError} + echo "Use following command to debug:" + echo "/home/admin/XXdebugLogs.sh" + exit 0 fi else From 6e3faa164cf44728a8ad73918e27c01b2799de22 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:02:21 +0100 Subject: [PATCH 131/162] break loop on error --- home.admin/00raspiblitz.sh | 3 +++ home.admin/80scanLND.sh | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 8442104..e7d2377 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -251,6 +251,9 @@ To run a BACKUP of funds & channels first is recommended. lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) if [ ${lndSynced} -eq 0 ]; then /home/admin/80scanLND.sh + if [ $? -gt 0 ]; then + exit 0 + fi else # everything is ready - return from loop return diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index e2c9b7f..925b401 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -20,7 +20,7 @@ if [ ${bitcoinActive} -eq 0 ]; then height=6 width=42 title="Blockchain Warning" - infoStr=" The ${network}d service is not running.\n Login for more details." + infoStr=" The ${network}d service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then infoStr="${infoStr}\n${bitcoinError}" fi @@ -34,7 +34,7 @@ elif [ ${lndActive} -eq 0 ]; then height=5 width=42 title="Lightning Warning" - infoStr=" The lnd service is not running.\n Login for more details." + infoStr=" The lnd service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then clear echo "*********************************" @@ -43,7 +43,7 @@ elif [ ${lndActive} -eq 0 ]; then echo ${lndError} echo "Use following command to debug:" echo "/home/admin/XXdebugLogs.sh" - exit 0 + exit 1 fi else From e3bf4114fdb681eb808acaac6f054c1026cf430d Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:03:55 +0100 Subject: [PATCH 132/162] admin error info --- home.admin/80scanLND.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 925b401..a9aad5b 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -22,7 +22,15 @@ if [ ${bitcoinActive} -eq 0 ]; then title="Blockchain Warning" infoStr=" The ${network}d service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then - infoStr="${infoStr}\n${bitcoinError}" + echo "" + echo "*********************************" + echo "* The ${network}d service is not running." + echo "*********************************" + echo ${bitcoinError} + echo "Use following command to debug:" + echo "/home/admin/XXdebugLogs.sh" + echo "" + exit 1 fi elif [ ${lndActive} -eq 0 ]; then @@ -36,13 +44,14 @@ elif [ ${lndActive} -eq 0 ]; then title="Lightning Warning" infoStr=" The lnd service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then - clear + echo "" echo "*********************************" echo "* The lnd service is not running." echo "*********************************" echo ${lndError} echo "Use following command to debug:" echo "/home/admin/XXdebugLogs.sh" + echo "" exit 1 fi From a198c5393ac8ad645a6b36af65f15163bf97fec2 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:09:38 +0100 Subject: [PATCH 133/162] more error info --- home.admin/80scanLND.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index a9aad5b..b70ca58 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -23,10 +23,19 @@ if [ ${bitcoinActive} -eq 0 ]; then infoStr=" The ${network}d service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then echo "" - echo "*********************************" + echo "*****************************************" echo "* The ${network}d service is not running." - echo "*********************************" - echo ${bitcoinError} + echo "*****************************************" + echo "If you just started some config/setup, this might be OK." + echo + if [ ${#bitcoinError} -gt 0 ]; then + echo "More Error Detail:" + echo ${bitcoinError} + echo + fi + echo "Use following command start ${network}d:" + echo "sudo systemctl start ${network}d" + echo echo "Use following command to debug:" echo "/home/admin/XXdebugLogs.sh" echo "" @@ -46,9 +55,18 @@ elif [ ${lndActive} -eq 0 ]; then if [ "$USER" == "admin" ]; then echo "" echo "*********************************" - echo "* The lnd service is not running." + echo "* The LND service is not running." echo "*********************************" - echo ${lndError} + echo "If you just started some config/setup, this might be OK." + echo + if [ ${#lndError} -gt 0 ]; then + echo "More Error Detail:" + echo ${lndError} + echo + fi + echo "Use following command start lnd:" + echo "sudo systemctl start lnd" + echo echo "Use following command to debug:" echo "/home/admin/XXdebugLogs.sh" echo "" From b9db03587a9197541d0c7955b532bb9c32e709f8 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:15:41 +0100 Subject: [PATCH 134/162] formatting progress --- home.admin/80scanLND.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index b70ca58..d07632f 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -84,15 +84,24 @@ else width=42 title="Node is Syncing (${scriptRuntime})" - # format progress values - if [ ${#syncProgress} -lt 6 ]; then - syncProgress=" ${syncProgress}" + # formatting progress values + if [ ${#syncProgress} -eq 0 ]; then + syncProgress="(waiting)" + elif [ ${#syncProgress} -lt 6 ]; then + syncProgress=" ${syncProgress} %" + else + syncProgress="${syncProgress} %" fi - if [ ${#scanProgress} -lt 6 ]; then - scanProgress=" ${scanProgress}" + if [ ${#scanProgress} -eq 0 ]; then + scanProgress="(waiting)" + elif [ ${#scanProgress} -lt 6 ]; then + scanProgress=" ${scanProgress} %" + else + scanProgress="${scanProgress} %" fi - infoStr=" Blockchain Progress : ${syncProgress} %\n Lightning Progress : ${scanProgress} %\n Please wait - this can take some time" + # setting info string + infoStr=" Blockchain Progress : ${syncProgress}\n Lightning Progress : ${scanProgress}\n Please wait - this can take some time" fi From 339cab954c87dfc6343c558db38a784a919e83ff Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:16:49 +0100 Subject: [PATCH 135/162] say info instead of wrning --- home.admin/80scanLND.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index d07632f..a7831b4 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -19,7 +19,7 @@ if [ ${bitcoinActive} -eq 0 ]; then height=6 width=42 - title="Blockchain Warning" + title="Blockchain Info" infoStr=" The ${network}d service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then echo "" @@ -50,7 +50,7 @@ elif [ ${lndActive} -eq 0 ]; then height=5 width=42 - title="Lightning Warning" + title="Lightning Info" infoStr=" The lnd service is not running.\n Login for more details:" if [ "$USER" == "admin" ]; then echo "" From 7685f81a9ea34d5337da9002569d8572312112a0 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:18:18 +0100 Subject: [PATCH 136/162] UI info --- home.admin/80scanLND.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index a7831b4..683439c 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -86,14 +86,14 @@ else # formatting progress values if [ ${#syncProgress} -eq 0 ]; then - syncProgress="(waiting)" + syncProgress="waiting" elif [ ${#syncProgress} -lt 6 ]; then syncProgress=" ${syncProgress} %" else syncProgress="${syncProgress} %" fi if [ ${#scanProgress} -eq 0 ]; then - scanProgress="(waiting)" + scanProgress="waiting" elif [ ${#scanProgress} -lt 6 ]; then scanProgress=" ${scanProgress} %" else From a481c134db366f4cdabccf7da852ea1050b146bc Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:22:44 +0100 Subject: [PATCH 137/162] let scanLND handle bitcoin --- home.admin/00infoLCD.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index b337d5c..d4efb4c 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -198,22 +198,22 @@ while : fi # check if bitcoin is ready - sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp - clienterror=`cat error.tmp` - rm error.tmp - if [ ${#clienterror} -gt 0 ]; then - boxwidth=40 - l1="Waiting for ${network}d to get ready.\n" - l2="---> ${clienterror/error*:/}\n" - l3="Can take longer if device was off." - uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')" - if [ ${uptimeSeconds} -gt 600 ]; then - l3="!!Please login for more details!!" - fi - dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - Welcome Back" --infobox "$l1$l2$l3" 5 ${boxwidth} - sleep 5 - continue - fi + #sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp + #clienterror=`cat error.tmp` + #rm error.tmp + #if [ ${#clienterror} -gt 0 ]; then + # boxwidth=40 + # l1="Waiting for ${network}d to get ready.\n" + # l2="---> ${clienterror/error*:/}\n" + # l3="Can take longer if device was off." + # uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')" + # if [ ${uptimeSeconds} -gt 600 ]; then + # l3="!!Please login for more details!!" + # fi + # dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - Welcome Back" --infobox "$l1$l2$l3" 5 ${boxwidth} + # sleep 5 + # continue + #fi # check if locked locked=$(sudo -u bitcoin lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) From b6dd3953a676147e8860585eae76973504da7028 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:34:53 +0100 Subject: [PATCH 138/162] Add startup grace time --- home.admin/80scanLND.sh | 86 +++++++++++-------- home.admin/config.scripts/blitz.statusscan.sh | 4 + 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 683439c..72e814b 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -20,26 +20,33 @@ if [ ${bitcoinActive} -eq 0 ]; then height=6 width=42 title="Blockchain Info" - infoStr=" The ${network}d service is not running.\n Login for more details:" - if [ "$USER" == "admin" ]; then - echo "" - echo "*****************************************" - echo "* The ${network}d service is not running." - echo "*****************************************" - echo "If you just started some config/setup, this might be OK." - echo - if [ ${#bitcoinError} -gt 0 ]; then - echo "More Error Detail:" - echo ${bitcoinError} + if [ ${uptime} -gt 300 ]; then + infoStr=" The ${network}d service is not running.\n Login for more details:" + if [ "$USER" == "admin" ]; then + echo "" + echo "*****************************************" + echo "* The ${network}d service is not running." + echo "*****************************************" + echo "If you just started some config/setup, this might be OK." echo + if [ ${#bitcoinError} -gt 0 ]; then + echo "More Error Detail:" + echo ${bitcoinError} + echo + fi + echo "Use following command start ${network}d:" + echo "sudo systemctl start ${network}d" + echo + echo "Use following command to debug:" + echo "/home/admin/XXdebugLogs.sh" + echo "" + exit 1 + fi + else + infoStr=" The ${network}d service is starting.\n Login for more details:" + if [ "$USER" == "admin" ]; then + infoStr=" The ${network}d service is starting.\n Please wait up to 5min ..." fi - echo "Use following command start ${network}d:" - echo "sudo systemctl start ${network}d" - echo - echo "Use following command to debug:" - echo "/home/admin/XXdebugLogs.sh" - echo "" - exit 1 fi elif [ ${lndActive} -eq 0 ]; then @@ -51,26 +58,33 @@ elif [ ${lndActive} -eq 0 ]; then height=5 width=42 title="Lightning Info" - infoStr=" The lnd service is not running.\n Login for more details:" - if [ "$USER" == "admin" ]; then - echo "" - echo "*********************************" - echo "* The LND service is not running." - echo "*********************************" - echo "If you just started some config/setup, this might be OK." - echo - if [ ${#lndError} -gt 0 ]; then - echo "More Error Detail:" - echo ${lndError} + if [ ${uptime} -gt 300 ]; then + infoStr=" The LND service is not running.\n Login for more details:" + if [ "$USER" == "admin" ]; then + echo "" + echo "*********************************" + echo "* The LND service is not running." + echo "*********************************" + echo "If you just started some config/setup, this might be OK." echo + if [ ${#lndError} -gt 0 ]; then + echo "More Error Detail:" + echo ${lndError} + echo + fi + echo "Use following command start lnd:" + echo "sudo systemctl start lnd" + echo + echo "Use following command to debug:" + echo "/home/admin/XXdebugLogs.sh" + echo "" + exit 1 + fi + else + infoStr=" The LND service is starting.\n Login for more details:" + if [ "$USER" == "admin" ]; then + infoStr=" The LND service is starting.\n Please wait up to 5min ..." fi - echo "Use following command start lnd:" - echo "sudo systemctl start lnd" - echo - echo "Use following command to debug:" - echo "/home/admin/XXdebugLogs.sh" - echo "" - exit 1 fi else diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 0f88a3b..b3951c2 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -24,6 +24,10 @@ echo "localIP='${localip}'" tempC=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc) echo "tempCelsius='${tempC}'" +# uptime in seconds +uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime) +echo "uptime=${uptime}" + # is bitcoind running bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running) echo "bitcoinActive=${bitcoinRunning}" From 7473b498a9b55f64e4f3de5a4941aa28d9d9c9e2 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:38:59 +0100 Subject: [PATCH 139/162] 80scanLND handles bitcoin info --- home.admin/00raspiblitz.sh | 17 +++++------------ home.admin/80scanLND.sh | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index e7d2377..df352d6 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -229,19 +229,12 @@ To run a BACKUP of funds & channels first is recommended. echo "${network} error: ${clienterror}" fi - # normal info - boxwidth=40 - l1="Waiting for ${network}d to get ready.\n" - l2="---> ${clienterror/error*:/}\n" - l3="Can take longer if device was off." - uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')" - # after 2 min show complete long string (full detail) - if [ ${uptimeSeconds} -gt 120 ]; then - boxwidth=80 - l2="${clienterror}\n" - l3="CTRL+C => terminal" + # let 80scanLND script to the info to use + /home/admin/80scanLND.sh + if [ $? -gt 0 ]; then + exit 0 fi - dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth} + else locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) if [ ${locked} -gt 0 ]; then diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 72e814b..deca55f 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -17,7 +17,7 @@ if [ ${bitcoinActive} -eq 0 ]; then # On Bitcoin Error #################### - height=6 + height=5 width=42 title="Blockchain Info" if [ ${uptime} -gt 300 ]; then From 9c602d22b461725f9040590fa45f1273f8036366 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:43:06 +0100 Subject: [PATCH 140/162] more start info --- home.admin/80scanLND.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index deca55f..4296f23 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -34,10 +34,11 @@ if [ ${bitcoinActive} -eq 0 ]; then echo ${bitcoinError} echo fi - echo "Use following command start ${network}d:" + echo "-> To try to start ${network}d run:" echo "sudo systemctl start ${network}d" - echo - echo "Use following command to debug:" + echo "-> To force Main Menu run:" + echo "/home/admin/00mainmenu.sh" + echo "-> Use following command to debug:" echo "/home/admin/XXdebugLogs.sh" echo "" exit 1 @@ -72,10 +73,11 @@ elif [ ${lndActive} -eq 0 ]; then echo ${lndError} echo fi - echo "Use following command start lnd:" + echo "-> To try to start LND run:" echo "sudo systemctl start lnd" - echo - echo "Use following command to debug:" + echo "-> To force Main Menu run:" + echo "/home/admin/00mainmenu.sh" + echo "-> Use following command to debug:" echo "/home/admin/XXdebugLogs.sh" echo "" exit 1 From d250dc01536372be888b9af57ef8ed3b8cedc218 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:44:55 +0100 Subject: [PATCH 141/162] shorten text info --- home.admin/80scanLND.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 4296f23..fdf1efd 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -34,12 +34,9 @@ if [ ${bitcoinActive} -eq 0 ]; then echo ${bitcoinError} echo fi - echo "-> To try to start ${network}d run:" - echo "sudo systemctl start ${network}d" - echo "-> To force Main Menu run:" - echo "/home/admin/00mainmenu.sh" - echo "-> Use following command to debug:" - echo "/home/admin/XXdebugLogs.sh" + echo "-> To start ${network}d run: sudo systemctl start ${network}d" + echo "-> To force Main Menu run: /home/admin/00mainmenu.sh" + echo "-> Use following command to debug: /home/admin/XXdebugLogs.sh" echo "" exit 1 fi @@ -73,12 +70,9 @@ elif [ ${lndActive} -eq 0 ]; then echo ${lndError} echo fi - echo "-> To try to start LND run:" - echo "sudo systemctl start lnd" - echo "-> To force Main Menu run:" - echo "/home/admin/00mainmenu.sh" - echo "-> Use following command to debug:" - echo "/home/admin/XXdebugLogs.sh" + echo "-> To start LND run: sudo systemctl start lnd" + echo "-> To force Main Menu run: /home/admin/00mainmenu.sh" + echo "-> Use following command to debug: /home/admin/XXdebugLogs.sh" echo "" exit 1 fi From b00b3b70dd11d1c45c7d8d6cded34c1060f70378 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 23:47:45 +0100 Subject: [PATCH 142/162] correct command info --- home.admin/80scanLND.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index fdf1efd..dd4b1ef 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -35,7 +35,7 @@ if [ ${bitcoinActive} -eq 0 ]; then echo fi echo "-> To start ${network}d run: sudo systemctl start ${network}d" - echo "-> To force Main Menu run: /home/admin/00mainmenu.sh" + echo "-> To force Main Menu run: /home/admin/00mainMenu.sh" echo "-> Use following command to debug: /home/admin/XXdebugLogs.sh" echo "" exit 1 @@ -71,7 +71,7 @@ elif [ ${lndActive} -eq 0 ]; then echo fi echo "-> To start LND run: sudo systemctl start lnd" - echo "-> To force Main Menu run: /home/admin/00mainmenu.sh" + echo "-> To force Main Menu run: /home/admin/00mainMenu.sh" echo "-> Use following command to debug: /home/admin/XXdebugLogs.sh" echo "" exit 1 From e1e4e48a6af4332dd5e0528aa4de135d71d66f13 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:03:36 +0100 Subject: [PATCH 143/162] Eroor Full & Short --- home.admin/00raspiblitz.sh | 3 +-- home.admin/80scanLND.sh | 13 +++++++------ home.admin/config.scripts/blitz.statusscan.sh | 10 ++++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index df352d6..9a2540b 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -225,13 +225,12 @@ To run a BACKUP of funds & channels first is recommended. exit fi - else - echo "${network} error: ${clienterror}" fi # let 80scanLND script to the info to use /home/admin/80scanLND.sh if [ $? -gt 0 ]; then + echo "${network} error: ${clienterror}" exit 0 fi diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index dd4b1ef..7b73c86 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -29,9 +29,9 @@ if [ ${bitcoinActive} -eq 0 ]; then echo "*****************************************" echo "If you just started some config/setup, this might be OK." echo - if [ ${#bitcoinError} -gt 0 ]; then + if [ ${#bitcoinErrorFull} -gt 0 ]; then echo "More Error Detail:" - echo ${bitcoinError} + echo ${bitcoinErrorFull} echo fi echo "-> To start ${network}d run: sudo systemctl start ${network}d" @@ -41,9 +41,10 @@ if [ ${bitcoinActive} -eq 0 ]; then exit 1 fi else - infoStr=" The ${network}d service is starting.\n Login for more details:" + height=6 + infoStr=" The ${network}d service is starting.\n${bitcoinErrorShort}\n Login for more details:" if [ "$USER" == "admin" ]; then - infoStr=" The ${network}d service is starting.\n Please wait up to 5min ..." + infoStr=" The ${network}d service is starting.\n${bitcoinErrorShort}\nPlease wait up to 5min ..." fi fi @@ -65,9 +66,9 @@ elif [ ${lndActive} -eq 0 ]; then echo "*********************************" echo "If you just started some config/setup, this might be OK." echo - if [ ${#lndError} -gt 0 ]; then + if [ ${#lndErrorFull} -gt 0 ]; then echo "More Error Detail:" - echo ${lndError} + echo ${lndErrorFull} echo fi echo "-> To start LND run: sudo systemctl start lnd" diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index b3951c2..a7064b7 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -38,10 +38,11 @@ if [ ${bitcoinRunning} -eq 1 ]; then blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/mnt/hdd/temp/.bitcoind.error) # check if error on request - bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null | tr "'" '"' | tr '"' '\"' ) + bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null) rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null if [ ${#bitcoinError} -gt 0 ]; then - echo "bitcoinError='${bitcoinError}'" + echo "bitcoinErrorFull='${bitcoinError}'" + echo "bitcoinErrorShort='${clienterror/error*:/}'" else ############################## @@ -77,10 +78,11 @@ if [ ${lndRunning} -eq 1 ]; then lndinfo=$(sudo -u bitcoin lncli getinfo 2>/mnt/hdd/temp/.lnd.error) # check if error on request - lndError=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null | tr "'" '"' | tr '"' '\"' ) + lndErrorFull=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null) rm /mnt/hdd/temp/.lnd.error 2>/dev/null if [ ${#lndError} -gt 0 ]; then - echo "lndError='${lndError}'" + echo "lndErrorFull='${lndErrorFull}'" + echo "lndErrorShort=''" else # synced to chain From cccdcfd704079e9591fa648dfef69a09e6f744ed Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:06:11 +0100 Subject: [PATCH 144/162] fix in case data is missing --- home.admin/config.scripts/blitz.statusscan.sh | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index a7064b7..a52a351 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -92,16 +92,18 @@ if [ ${lndRunning} -eq 1 ]; then # lnd scan progress scanTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp') echo "scanTimestamp=${scanTimestamp}" - scanDate=$(date -d @${scanTimestamp}) - echo "scanDate='${scanDate}'" - - # calculate LND scan progress by seconds since Genesisblock - genesisTimestamp=1230940800 - nowTimestamp=$(date +%s) - totalSeconds=$(echo "${nowTimestamp}-${genesisTimestamp}" | bc) - scannedSeconds=$(echo "${scanTimestamp}-${genesisTimestamp}" | bc) - scanProgress=$(echo "scale=2; $scannedSeconds*100/$totalSeconds" | bc) - echo "scanProgress=${scanProgress}" + if [ ${#scanTimestamp} -gt 0 ]; then + scanDate=$(date -d @${scanTimestamp}) + echo "scanDate='${scanDate}'" + + # calculate LND scan progress by seconds since Genesisblock + genesisTimestamp=1230940800 + nowTimestamp=$(date +%s) + totalSeconds=$(echo "${nowTimestamp}-${genesisTimestamp}" | bc) + scannedSeconds=$(echo "${scanTimestamp}-${genesisTimestamp}" | bc) + scanProgress=$(echo "scale=2; $scannedSeconds*100/$totalSeconds" | bc) + echo "scanProgress=${scanProgress}" + fi fi From 766bbdcf1355f9ae261b245038d5912d52b4c7a9 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:07:12 +0100 Subject: [PATCH 145/162] debug --- home.admin/config.scripts/blitz.statusscan.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index a52a351..c708288 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -39,7 +39,7 @@ if [ ${bitcoinRunning} -eq 1 ]; then # check if error on request bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null) - rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null + #rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null if [ ${#bitcoinError} -gt 0 ]; then echo "bitcoinErrorFull='${bitcoinError}'" echo "bitcoinErrorShort='${clienterror/error*:/}'" @@ -79,7 +79,7 @@ if [ ${lndRunning} -eq 1 ]; then # check if error on request lndErrorFull=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null) - rm /mnt/hdd/temp/.lnd.error 2>/dev/null + #rm /mnt/hdd/temp/.lnd.error 2>/dev/null if [ ${#lndError} -gt 0 ]; then echo "lndErrorFull='${lndErrorFull}'" echo "lndErrorShort=''" From b8d90e59dbac3cf86b33c4fefaa75faed5f05707 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:12:43 +0100 Subject: [PATCH 146/162] remove ending lines --- home.admin/config.scripts/blitz.statusscan.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index c708288..14e2a45 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -114,6 +114,4 @@ fi # info on scan run time endTime=$(date +%s) runTime=$(echo "${endTime}-${startTime}" | bc) -echo "scriptRuntime=${runTime}" - - +echo "scriptRuntime=${runTime}" \ No newline at end of file From 73a616a3b053303cff0b424fef6dece99abe669c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:17:25 +0100 Subject: [PATCH 147/162] debug --- home.admin/config.scripts/blitz.statusscan.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 14e2a45..fe0e7d9 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -35,14 +35,14 @@ echo "bitcoinActive=${bitcoinRunning}" if [ ${bitcoinRunning} -eq 1 ]; then # get blockchain info - blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/mnt/hdd/temp/.bitcoind.error) - + sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/mnt/hdd/temp/.bitcoind.out 2>/mnt/hdd/temp/.bitcoind.error # check if error on request + blockchaininfo=$(cat /mnt/hdd/temp/.bitcoind.out 2>/dev/null) bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null) #rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null if [ ${#bitcoinError} -gt 0 ]; then echo "bitcoinErrorFull='${bitcoinError}'" - echo "bitcoinErrorShort='${clienterror/error*:/}'" + echo "bitcoinErrorShort='${bitcoinError/error*:/}'" else ############################## From 29381b6831a6dea1c7d5b1b4dfdea35810b07cbc Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:26:30 +0100 Subject: [PATCH 148/162] display error --- home.admin/00infoLCD.sh | 18 ------------------ home.admin/80scanLND.sh | 4 ++-- home.admin/config.scripts/blitz.statusscan.sh | 3 ++- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index d4efb4c..650acd8 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -197,24 +197,6 @@ while : continue fi - # check if bitcoin is ready - #sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp - #clienterror=`cat error.tmp` - #rm error.tmp - #if [ ${#clienterror} -gt 0 ]; then - # boxwidth=40 - # l1="Waiting for ${network}d to get ready.\n" - # l2="---> ${clienterror/error*:/}\n" - # l3="Can take longer if device was off." - # uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')" - # if [ ${uptimeSeconds} -gt 600 ]; then - # l3="!!Please login for more details!!" - # fi - # dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - Welcome Back" --infobox "$l1$l2$l3" 5 ${boxwidth} - # sleep 5 - # continue - #fi - # check if locked locked=$(sudo -u bitcoin lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) if [ "${locked}" -gt 0 ]; then diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 7b73c86..376b129 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -11,7 +11,7 @@ if [ "$USER" == "admin" ]; then adminStr="Use CTRL+c to EXIT to Terminal" fi -if [ ${bitcoinActive} -eq 0 ]; then +if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then #################### # On Bitcoin Error @@ -48,7 +48,7 @@ if [ ${bitcoinActive} -eq 0 ]; then fi fi -elif [ ${lndActive} -eq 0 ]; then +elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ]; then #################### # On LND Error diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index fe0e7d9..3607051 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -42,7 +42,8 @@ if [ ${bitcoinRunning} -eq 1 ]; then #rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null if [ ${#bitcoinError} -gt 0 ]; then echo "bitcoinErrorFull='${bitcoinError}'" - echo "bitcoinErrorShort='${bitcoinError/error*:/}'" + bitcoinErrorShort=$(echo ${bitcoinError/error*:/} | sed 's/[^a-zA-Z0-9 ]//g') + echo "bitcoinErrorShort='${bitcoinErrorShort}'" else ############################## From 9d753c66ab855b67d7d62551aa668ef3518fd314 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:28:18 +0100 Subject: [PATCH 149/162] default start info --- home.admin/80scanLND.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 376b129..6259e49 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -42,6 +42,9 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then fi else height=6 + if [ ${#bitcoinErrorShort} -eq 0 ]; then + bitcoinErrorShort="Initial Startup" + fi infoStr=" The ${network}d service is starting.\n${bitcoinErrorShort}\n Login for more details:" if [ "$USER" == "admin" ]; then infoStr=" The ${network}d service is starting.\n${bitcoinErrorShort}\nPlease wait up to 5min ..." From 380d9f5ef576145161e9e2ff196b2f0cb54df9fc Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:30:39 +0100 Subject: [PATCH 150/162] Formatting --- home.admin/80scanLND.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 6259e49..3768b7c 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -18,7 +18,7 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then #################### height=5 - width=42 + width=43 title="Blockchain Info" if [ ${uptime} -gt 300 ]; then infoStr=" The ${network}d service is not running.\n Login for more details:" @@ -45,9 +45,9 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then if [ ${#bitcoinErrorShort} -eq 0 ]; then bitcoinErrorShort="Initial Startup" fi - infoStr=" The ${network}d service is starting.\n${bitcoinErrorShort}\n Login for more details:" + infoStr=" The ${network}d service is starting.\n ${bitcoinErrorShort}\n Login for more details:" if [ "$USER" == "admin" ]; then - infoStr=" The ${network}d service is starting.\n${bitcoinErrorShort}\nPlease wait up to 5min ..." + infoStr=" The ${network}d service is starting.\n ${bitcoinErrorShort}\nPlease wait up to 5min ..." fi fi @@ -58,7 +58,7 @@ elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ]; then #################### height=5 - width=42 + width=43 title="Lightning Info" if [ ${uptime} -gt 300 ]; then infoStr=" The LND service is not running.\n Login for more details:" @@ -95,7 +95,7 @@ else # basic dialog info height=6 - width=42 + width=43 title="Node is Syncing (${scriptRuntime})" # formatting progress values From 07eb873363884ca7121570a75ef1f1b4d80a5496 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:31:59 +0100 Subject: [PATCH 151/162] initial info --- home.admin/80scanLND.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 3768b7c..45c175a 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -43,11 +43,11 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then else height=6 if [ ${#bitcoinErrorShort} -eq 0 ]; then - bitcoinErrorShort="Initial Startup" + bitcoinErrorShort="Initial Startup - Please Wait" fi - infoStr=" The ${network}d service is starting.\n ${bitcoinErrorShort}\n Login for more details:" + infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Login for more details:" if [ "$USER" == "admin" ]; then - infoStr=" The ${network}d service is starting.\n ${bitcoinErrorShort}\nPlease wait up to 5min ..." + infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\nPlease wait up to 5min ..." fi fi From c0be768ae3bc5e2a26e2095869e70e56716de24a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:41:58 +0100 Subject: [PATCH 152/162] autunlock grace time --- home.admin/00raspiblitz.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 9a2540b..868f892 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -237,8 +237,14 @@ To run a BACKUP of funds & channels first is recommended. else locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) if [ ${locked} -gt 0 ]; then - /home/admin/AAunlockLND.sh - echo "please wait ... update to next screen can be slow" + uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime) + if [ "${autoUnlock}" == "on" ] && [ ${uptime} -lt 240 ]; then + # give autounlock 4 min after startup to react + sleep 1 + else + /home/admin/AAunlockLND.sh + echo "please wait ... update to next screen can be slow" + fi fi lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) if [ ${lndSynced} -eq 0 ]; then From 57b8daf8cf0962467d3dd2cbc266166fb9893268 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:44:18 +0100 Subject: [PATCH 153/162] small UI fix --- home.admin/80scanLND.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 45c175a..ffd2711 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -47,7 +47,7 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then fi infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Login for more details:" if [ "$USER" == "admin" ]; then - infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\nPlease wait up to 5min ..." + infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Please wait up to 5min ..." fi fi From 801c3120a94eaedeb0ca4bd58436176e3cc5fd03 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 00:48:26 +0100 Subject: [PATCH 154/162] wait 5min for autounlock --- home.admin/00raspiblitz.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 868f892..4165c88 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -238,8 +238,8 @@ To run a BACKUP of funds & channels first is recommended. locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) if [ ${locked} -gt 0 ]; then uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime) - if [ "${autoUnlock}" == "on" ] && [ ${uptime} -lt 240 ]; then - # give autounlock 4 min after startup to react + if [ "${autoUnlock}" == "on" ] && [ ${uptime} -lt 300 ]; then + # give autounlock 5 min after startup to react sleep 1 else /home/admin/AAunlockLND.sh From 91925230156216e728df7ef942144ab9be4fe7c6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 01:39:33 +0100 Subject: [PATCH 155/162] #369 update to 0.6 final --- build_sdcard.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_sdcard.sh b/build_sdcard.sh index 98477e5..b70b468 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -419,8 +419,8 @@ echo "*** LND ***" ## based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#lightning-lnd ## see LND releases: https://github.com/lightningnetwork/lnd/releases -lndVersion="0.6-beta-rc4" -lndSHA256="3ed4b5e54afb6bf083a9693058dbf7d490e15837da5e5dc49ba06bfb942a1312" +lndVersion="0.6-beta" +lndSHA256="effea372c207293fd42b0cc27800da3a70c22f8c9a0e7b5eb8dbe56b5b98e1a3" # olaoluwa PGPpkeys="https://keybase.io/roasbeef/pgp_keys.asc" From e42eea633a5a8859734e731a8332eaa8278ddcdc Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 03:23:46 +0100 Subject: [PATCH 156/162] small UI update --- home.admin/20recoverDialog.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/20recoverDialog.sh b/home.admin/20recoverDialog.sh index d9cce91..b7c80e8 100755 --- a/home.admin/20recoverDialog.sh +++ b/home.admin/20recoverDialog.sh @@ -46,6 +46,7 @@ ACTUAL/OLD Password C to re-activate the Auto-Unlock feature. Enter a empty password to deactivate the Auto-Unlock feature. " 10 52 + echo "Activating Auto-Unlock (please wait) .." sudo /home/admin/config.scripts/lnd.autounlock.sh on dialog --backtitle "RaspiBlitz" --msgbox "FINAL REBOOT IS NEEDED." 6 52 From 3fcf786d6ce26bc4ccd897b66369a5be385cc292 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 03:24:26 +0100 Subject: [PATCH 157/162] Experimental Notice on Backup Torrent Seeding --- home.admin/00settingsMenuServices.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/home.admin/00settingsMenuServices.sh b/home.admin/00settingsMenuServices.sh index 44d04e8..c29939d 100644 --- a/home.admin/00settingsMenuServices.sh +++ b/home.admin/00settingsMenuServices.sh @@ -222,9 +222,16 @@ if [ "${backupTorrentSeeding}" != "${choice}" ]; then echo "BACKUP TORRENT SEEDING Setting changed .." anychange=1 if [ "${choice}" = "on" ]; then - /home/admin/50torrentHDD.sh backup-torrent-hosting - dialog --backtitle "RaspiBlitz Settings" --title " OK " --msgbox " + whiptail --title "Experimental Feature" --yes-button "Activate" --no-button "Dont Activate" --yesno "The Backup Torrent Seeding is still a very early +experimental feature and could compromise your +Lightning Node stability. + +Are you sure that you want to activate it? + " 11 54 + if [ $? -eq 0 ]; then + /home/admin/50torrentHDD.sh backup-torrent-hosting + dialog --backtitle "RaspiBlitz Settings" --title " OK " --msgbox " BACKUP TORRENT SEEDING IS NOW ACTIVE ------------------------------------- If possible forward ports 49200-49250 @@ -234,6 +241,12 @@ During initial torrent download your RaspiBlitz can be slow. " 13 42 + else + echo + echo "Skipping Backup Torrent Seeding ..." + echo + sleep 3 + fi else echo "Stopping Torrents and Cleaning Up ..." From 48ecfb614b9a520ce05228c25ed35f34f259e041 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 03:31:51 +0100 Subject: [PATCH 158/162] main menu local ip --- home.admin/00mainMenu.sh | 3 +++ home.admin/00raspiblitz.sh | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index dc34c90..1f3108e 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -11,6 +11,9 @@ infoFile="/home/admin/raspiblitz.info" source ${infoFile} source ${configFile} +# get the local network IP to be displayed on the lCD +localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + # BASIC MENU INFO HEIGHT=13 WIDTH=64 diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 4165c88..3072b60 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -131,9 +131,6 @@ OPTIONS=() # check if RTL web interface is installed runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') -# get the local network IP to be displayed on the lCD -localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - # function to use later waitUntilChainNetworkIsReady() { From c170ed524b4456e717f087071cf5e3e1e0dbe3ab Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 03:36:30 +0100 Subject: [PATCH 159/162] rename software test --- home.admin/00mainMenu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 1f3108e..def87d7 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -67,7 +67,7 @@ fi # final Options OPTIONS+=(HARDWARE "Run Hardwaretest") -OPTIONS+=(SOFTWARE "Run Softwaretest") +OPTIONS+=(SOFTWARE "Run Softwaretest (DebugReport)") OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update") OPTIONS+=(OFF "PowerOff RaspiBlitz") OPTIONS+=(X "Console / Terminal") From 07f5ff904e29e8ea9b13dc8b44ba9d9da4451434 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 03:45:54 +0100 Subject: [PATCH 160/162] Readme Version Update --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 86deec0..35cbd48 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # RaspiBlitz *Build your own Lightning Node on a RaspberryPi with a nice Display.* -`Version 1.1 with lnd 0.6-beta-RC3 and bitcoin 0.17.1 or litecoin 0.16.3.` +`Version 1.2 with lnd 0.6-beta and bitcoin 0.17.1 or litecoin 0.16.3.` ![RaspiBlitz](pictures/raspiblitz.jpg) @@ -587,5 +587,3 @@ Also get inspired for a deep-dive with the original "[RaspiBolt](https://github. Join me on twitter [@rootzoll](https://twitter.com/rootzoll), visit us at a upcomming [#lightninghackday](https://twitter.com/hashtag/LightningHackday?src=hash) or check by on of our bitcoin meetups in Berlin ... every 1st Thursday evening a month at the room77 bar - feel free to buy me a beer with lightning there :) * [How can I get further help/support?](#support) - -IRC channel on Freenode `irc://irc.freenode.net/raspiblitz` (unmoderated) From 4c281ad09d60d73f5e2f68e3c1798ea63734c291 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 03:51:01 +0100 Subject: [PATCH 161/162] debug --- home.admin/_background.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/home.admin/_background.sh b/home.admin/_background.sh index 3945085..0533f5c 100644 --- a/home.admin/_background.sh +++ b/home.admin/_background.sh @@ -158,12 +158,12 @@ do # check every 1min recheckSCB=$(($counter % 60)) if [ ${recheckSCB} -eq 1 ]; then - #echo "SCB Monitoring ..." + echo "SCB Monitoring ..." source ${configFile} # check if channel.backup exists scbExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | grep -c 'channel.backup') if [ ${scbExists} -eq 1 ]; then - #echo "Found Channel Backup File .. check if changed .." + echo "Found Channel Backup File .. check if changed .." md5checksumORG=$(sudo md5sum /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) md5checksumCPY=$(sudo md5sum /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1) if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then @@ -207,11 +207,11 @@ do fi fi - #else - # echo "Channel Backup File not changed." + else + echo "Channel Backup File not changed." fi - #else - # echo "No Channel Backup File .." + else + echo "No Channel Backup File .." fi fi @@ -223,25 +223,25 @@ do recheckSync=$(($counter % 300)) if [ ${recheckSync} -eq 1 ]; then source ${configFile} - #echo "LND MONITOR LOST SYNC ..." + echo "LND MONITOR LOST SYNC ..." lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) - #echo "lndSynced(${lndSynced})" - #echo "syncedSince(${syncedSince})" - #echo "lastSyncState(${lastSyncState})" + echo "lndSynced(${lndSynced})" + echo "syncedSince(${syncedSince})" + echo "lastSyncState(${lastSyncState})" if [ ${lndSynced} -eq ${lastSyncState} ]; then - #echo "no sync change" + echo "no sync change" if [ ${lndSynced} -eq 1 ]; then - #echo "all is good - LND still in sync now for:" + echo "all is good - LND still in sync now for:" actualSecondsTimestamp=$(date +%s) secondsInSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) #echo "${secondsInSync} seconds" # when >10min in sync if [ ${secondsInSync} -gt 3600 ]; then - #echo "LND in sync for longer then 1 hour" + echo "LND in sync for longer then 1 hour" if [ "${backupTorrentSeeding}" == "on" ]; then - #echo "Backup Torrent Seeding is ON - check if already running" + echo "Backup Torrent Seeding is ON - check if already running" source <(sudo -u admin /home/admin/50torrentHDD.sh status) if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then echo "---> STARTING Backup Torrent Seeding" @@ -251,13 +251,13 @@ do fi else - #echo "still not in sync" + echo "still not in sync" if [ ${syncedSince} -gt 0 ]; then - #echo "was in sync at least once since rinning but lost now for:" + echo "was in sync at least once since rinning but lost now for:" actualSecondsTimestamp=$(date +%s) secondsOutOfSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc) - #echo "${secondsOutOfSync} seconds" + echo "${secondsOutOfSync} seconds" # when >1h out of sync #if [ ${secondsOutOfSync} -gt 3600 ]; then From 98baf5f68804f1ff412623db30ececb5f44f2868 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 17 Apr 2019 04:01:11 +0100 Subject: [PATCH 162/162] detail on channel.backup error --- home.admin/70initLND.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 2e00b6e..6778351 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -483,7 +483,7 @@ fi echo "" ###### USE CHANNEL.BACKUP FILE IF AVAILABLE -echo "*** SCB Recovery ***" +echo "*** channel.backup Recovery ***" gotSCB=$(ls /home/admin/channel.backup | grep -c 'channel.backup') if [ ${gotSCB} -eq 1 ]; then @@ -494,11 +494,22 @@ if [ ${gotSCB} -eq 1 ]; then if [ ${#error} -gt 0 ]; then echo "" echo "!!! FAIL !!! SOMETHING WENT WRONG:" - echo "${error}" + + notMachtingSeed=$(echo $error | grep -c 'unable to unpack chan backup') + if [ ${notMachtingSeed} -gt 0 ]; then + echo "--> unable to unpack chan backup" + echo "The WORD SEED is not matching the channel.backup file." + echo "Either there was an error in the word seed list or" + echo "or the channel.backup file is from another RaspiBlitz." + else + echo "${error}" + fi + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "" - echo "You can try after full setup to restore channel.backup file again." - echo "Press ENTER to continue ..." + echo "You can try after full setup to restore channel.backup file again with:" + echo "lncli restorechanbackup --multi_file=/home/admin/channel.backup" + echo "Press ENTER to continue for now ..." read key exit 1 fi