only show seedwords if present on ENCRYPT

This commit is contained in:
openoms
2021-08-31 14:54:33 +01:00
parent a66821eeba
commit 2586f46ea7

View File

@@ -188,12 +188,11 @@ if [ "$1" = "new" ] || [ "$1" = "new-force" ] || [ "$1" = "seed" ] || [ "$1" = "
sudo chown bitcoin:bitcoin /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info
sudo chmod 600 /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info
echo "
# this file was placed by cln.hsmtool.sh
# contains the seed words from which the hsm_secret in the same directory was generated
# This file was placed by cln.hsmtool.sh .
# Contains the seed words from which the hsm_secret in the same directory was generated
seedwords='${seedwords}'
seedwords6x4='${seedwords6x4}'
# will be removed safely when the hsm_secret is encrypted
# the words cannot be generated from the hsm_secret (one way function)
# Will be removed safely when the hsm_secret is encrypted.
" | sudo -u bitcoin tee /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info
# pass to 'hsmtool generatehsm hsm_secret'
@@ -260,24 +259,29 @@ elif [ "$1" = "lock" ]; then
exit 0
elif [ "$1" = "encrypt" ]; then
# show the words one last time
source <(sudo -u bitcoin cat /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info)
ack=0
while [ ${ack} -eq 0 ]
do
whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" --msgbox "The backup of seedwords will be deleted, make sure you wrote them down. Store these numbered 24 words in a safe location:\n\n${seedwords6x4}" 13 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
done
# delete seedwords.info
sudo -u bitcoin shred /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info
if [ -f /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info ];then
# show the words one last time
source <(sudo -u bitcoin cat /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info)
ack=0
while [ ${ack} -eq 0 ]
do
whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" --msgbox "The backup of seedwords will be deleted, make sure you wrote them down. Store these numbered 24 words in a safe location:\n\n${seedwords6x4}" 13 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
done
# delete seedwords.info
sudo -u bitcoin shred /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info
deletedWhen=" "
else
deletedWhen="not available any more"
fi
echo "
# this file is placed by cln.hsmtool.sh
# the seed words from which the hsm_secret in the same directory was generated
# were deleted when the hsm_secret was encrypted
# the words cannot be generated from the hsm_secret (one way function)
# This file is placed by cln.hsmtool.sh .
# The seed words from which the hsm_secret in the same directory was generated
# were $deletedWhen.
# The words cannot be generated from the hsm_secret (one way function).
# If you don't have the words the hsm_secret can be still backed up in hex:
# https://lightning.readthedocs.io/BACKUP.html#hsm-secret
" | sudo -u bitcoin tee /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info