SCB fallback

This commit is contained in:
Christian Rotzoll 2019-04-16 16:01:57 +01:00
parent 23b1e9dd56
commit 680ff4684a
2 changed files with 159 additions and 133 deletions

View file

@ -213,7 +213,17 @@ if [ ${walletExists} -eq 0 ]; then
ONLYSEED "Only Seed Word List (FALLBACK)") 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) 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 if [ "${CHOICE}" == "ONLYSEED" ]; then
whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno " whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno "
Using JUST SEED WORDS will only recover your on-chain funds. 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
fi fi
# let user enter password c ##### DEACTIVATED UNTIL config.scripts/lnd.initwallet.py WORKS
sudo shred /home/admin/.pass.tmp 2>/dev/null # # let user enter password c
sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp # sudo shred /home/admin/.pass.tmp 2>/dev/null
passwordC=`sudo cat /home/admin/.pass.tmp` # sudo ./config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp
sudo shred /home/admin/.pass.tmp 2>/dev/null # 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 # # 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 # # dialog to enter
wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9,]//g' ) # 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
shred /home/admin/.seed.tmp # wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9,]//g' )
echo "processing ... ${wordstring}" # shred /home/admin/.seed.tmp
# echo "processing ... ${wordstring}"
# check correct number of words #
IFS=',' read -r -a seedArray <<< "$wordstring" # # check correct number of words
if [ ${#seedArray[@]} -eq 24 ]; then # IFS=',' read -r -a seedArray <<< "$wordstring"
echo "OK - 24 words" # if [ ${#seedArray[@]} -eq 24 ]; then
else # echo "OK - 24 words"
whiptail --title " WARNING " --msgbox " # else
The word list has ${#seedArray[@]} words. But it must be 24. # whiptail --title " WARNING " --msgbox "
Please check your list and try again. #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. #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, ... #The Word list should look like this:
#wordone,wordtweo,wordthree, ...
" 16 52 #
/home/admin/70initLND.sh #" 16 52
exit 1 # /home/admin/70initLND.sh
fi # exit 1
# fi
# ask if seed was protected by password D #
passwordD="" # # ask if seed was protected by password D
dialog --title "SEED PASSWORD" --yes-button "No extra Password" --no-button "Yes" --yesno " # passwordD=""
Are your seed words protected by an extra password? # 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. #During wallet creation LND offers to set an extra password
" 11 65 #to protect the seed words. Most users did not set this.
if [ $? -eq 1 ]; then # " 11 65
sudo shred /home/admin/.pass.tmp 2>/dev/null # if [ $? -eq 1 ]; then
sudo ./config.scripts/blitz.setpassword.sh x "Enter extra Password D" /home/admin/.pass.tmp # sudo shred /home/admin/.pass.tmp 2>/dev/null
passwordD=`sudo cat /home/admin/.pass.tmp` # sudo ./config.scripts/blitz.setpassword.sh x "Enter extra Password D" /home/admin/.pass.tmp
sudo shred /home/admin/.pass.tmp 2>/dev/null # passwordD=`sudo cat /home/admin/.pass.tmp`
fi # sudo shred /home/admin/.pass.tmp 2>/dev/null
# fi
fi #
# fi
if [ "${CHOICE}" == "ONLYSEED" ]; then #
# if [ "${CHOICE}" == "ONLYSEED" ]; then
# trigger wallet recovery #
source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} ${wordstring} ${passwordD}) # # 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 # # on success the python script should return the seed words again
dialog --title " SUCCESS " --msgbox " # if [ ${#seedwords} -gt 1 ]; then
Looks good :) LND was able to recover the wallet. # dialog --title " SUCCESS " --msgbox "
" 7 53 #Looks good :) LND was able to recover the wallet.
else # " 7 53
if [ ${#err} -eq 0 ]; then # else
echo # if [ ${#err} -eq 0 ]; then
echo "FAIL!! Unkown Error - check output above for any hints and report to development." # echo
echo "PRESS ENTER to try again." # echo "FAIL!! Unkown Error - check output above for any hints and report to development."
read key # echo "PRESS ENTER to try again."
/home/admin/70initLND.sh # read key
exit 1 # /home/admin/70initLND.sh
else # exit 1
whiptail --title " FAIL " --msgbox " # else
Something went wrong - see info below: # whiptail --title " FAIL " --msgbox "
${err} #Something went wrong - see info below:
${errMore} #${err}
" 13 72 #${errMore}
/home/admin/70initLND.sh # " 13 72
exit 1 # /home/admin/70initLND.sh
fi # exit 1
fi # fi
# fi
elif [ "${CHOICE}" == "SEED+SCB" ]; then # fi
if [ "${CHOICE}" == "SEED+SCB" ]; then
# get the channel.backup file # get the channel.backup file
gotFile=-1 gotFile=-1
@ -355,52 +366,62 @@ ${errMore}
clear clear
echo "OK - channel.backup file found." 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 ##### FALLBACK UNTIL config.scripts/lnd.initwallet.py WORKS
# on success the python script should return the seed words again echo "****************************************************************************"
if [ ${#seedwords} -gt 1 ]; then echo "Helping Instructions --> for recovering a LND Wallet"
dialog --title " SUCCESS " --msgbox " echo "****************************************************************************"
Looks good :) LND was able to recover the wallet. echo "A) For 'Wallet Password' use your old PASSWORD C"
" 7 53 echo "B) For 'cipher seed mnemonic' answere 'y' and enter words sepereted by space"
else echo "C) Enter 'passphrase' to encrypt your 'cipher seed' only if u did on create"
if [ ${#err} -eq 0 ]; then echo "****************************************************************************"
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
echo "" echo ""
echo "PRESS ENTER to continue." sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>$_error
read key error=`cat ${_error}`
/home/admin/70initLND.sh
exit 1
else if [ ${#error} -gt 0 ]; then
echo "CANCEL" echo ""
echo "!!! FAIL !!! SOMETHING WENT WRONG:"
echo "${error}"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "Press ENTER to retry ..."
read key
echo "Starting RETRY ..."
/home/admin/70initLND.sh /home/admin/70initLND.sh
exit 1 exit 1
fi fi
# FALLBACK /home/admin/70initLND.sh
#dialog --title "OK" --msgbox "\nI will start 'lncli create' for you ..." 7 44
#sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create ##### DEACTIVATED UNTIL config.scripts/lnd.initwallet.py WORKS
#/home/admin/70initLND.sh # # 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 fi
@ -458,6 +479,18 @@ if [ ${locked} -gt 0 ]; then
else else
echo "OK - Wallet is already unlocked" echo "OK - Wallet is already unlocked"
fi 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%) # set SetupState (scan is done - so its 80%)
sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info

View file

@ -128,21 +128,14 @@ if mode=="new":
elif mode=="seed": elif mode=="seed":
print("# wallet passphrase: "+walletpassword) print("err='TODO: debug creating from seed")
sys.exit(1)
request = ln.InitWalletRequest( request = ln.InitWalletRequest(
wallet_password=walletpassword, wallet_password=walletpassword,
cipher_seed_mnemonic=seedwords, cipher_seed_mnemonic=seedwords,
recovery_window=1000, 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: try: