From 2586f46ea70fedf6a64c0072178d23ab3408823a Mon Sep 17 00:00:00 2001 From: openoms Date: Tue, 31 Aug 2021 14:54:33 +0100 Subject: [PATCH] only show seedwords if present on ENCRYPT --- home.admin/config.scripts/cln.hsmtool.sh | 46 +++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/home.admin/config.scripts/cln.hsmtool.sh b/home.admin/config.scripts/cln.hsmtool.sh index 47ff18c30..b2a53f3c1 100644 --- a/home.admin/config.scripts/cln.hsmtool.sh +++ b/home.admin/config.scripts/cln.hsmtool.sh @@ -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