add seed-force

This commit is contained in:
rootzoll 2021-07-17 00:54:31 +02:00
parent 71420a0e23
commit 2c218d35b4
2 changed files with 45 additions and 9 deletions

View File

@ -348,15 +348,49 @@ if [ "${lightning}" == "cln" ]; then
###################################
# c-lightning
echo "############## c-lightning" >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Install'/g" ${infoFile}
sudo /home/admin/config.scripts/cln.install.sh on mainnet >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Setup'/g" ${infoFile}
echo "############## Install c-lightning" >> ${logFile}
sudo /home/admin/config.scripts/cln.install.sh >> ${logFile}
# OLD WALLET FROM CLIGHTNING RESCUE
if [ "${lndrescue}" != "" ]; then
# these vars are available from the setup process for cln loaded from setupfile
# seedWords --> if entered on old seed
# clnrescue --> if user uploaded a rescue file
# setPasswordC --> for any new wallet encryption
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='setup: implement clnrescue'/g" ${infoFile}
echo "FAIL: setup: implement clnrescue" >> ${logFile}
exit 1
# OLD WALLET FROM SEEDWORDS
else [ "${seedwords}" != "" ]; then
source <(sudo /home/admin/config.scripts/cln.hsmtool.sh seed-force mainnet "${seedwords}")
# NEW WALLET
else
# sudo /home/admin/config.scripts/cln.hsmtool.sh seed-force mainnet "dad march erode large digital fun lift squirrel zebra order label inquiry distance tube predict benefit skin insect mistake bullet solar ostrich shiver road"
# generate new wallet
source <(sudo /home/admin/config.scripts/cln.hsmtool.sh new-force mainnet)
# check if got new seedwords
if [ "${seedwords}" == "" ] || [ "${seedwords6x4}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='setup: no cln seedwords'/g" ${infoFile}
echo "FAIL: setup: no cln seedwords" >> ${logFile}
exit 1
fi
# write created seedwords into SETUPFILE to be displayed to user on final setup later
echo "seedwordsNEW='${seedwords}'" >> ${setupFile}
echo "seedwords6x4NEW='${seedwords6x4}'" >> ${setupFile}
fi
# TODO setPasswordC --> for any new wallet encryption
fi

View File

@ -20,7 +20,9 @@ if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]||\
echo "# new-force will delete any old wallet and will work without dialog"
echo
echo "# cln.hsmtool.sh [seed] [mainnet|testnet|signet] [\"space-separated-seed-words\"] [?seedPassword]"
echo "# cln.hsmtool.sh [seed-force] [mainnet|testnet|signet] [\"space-separated-seed-words\"] [?seedPassword]"
echo "# the new hsm_secret will be not encrypted if no NewPassword is given"
echo "# seed-force will delete any old wallet and will work without dialog"
echo
echo "# cln.hsmtool.sh [unlock|lock] <mainnet|testnet|signet>"
echo "# cln.hsmtool.sh [encrypt|decrypt] <mainnet|testnet|signet>"
@ -140,10 +142,10 @@ function decryptHSMsecret() {
###########
# Options #
###########
if [ "$1" = "new" ] || [ "$1" = "new-force" ] || [ "$1" = "seed" ]; then
if [ "$1" = "new" ] || [ "$1" = "new-force" ] || [ "$1" = "seed" ] || [ "$1" = "seed-force" ]; then
# check/delete existing wallet
if [ "$1" = "new-force" ]; then
if [ "$1" = "new-force" ] || [ "$1" = "seed-force" ]; then
echo "# deleting any old wallet ..."
sudo rm $hsmSecretPath
else
@ -169,7 +171,7 @@ if [ "$1" = "new" ] || [ "$1" = "new-force" ] || [ "$1" = "seed" ]; then
source <(python /home/admin/config.scripts/blitz.mnemonic.py)
echo "seedwords='${seedwords}'"
echo "seedwords6x4='${seedwords6x4}'"
elif [ "$1" = "seed" ]; then
elif [ "$1" = "seed" ] || [ "$1" = "seed-force" ]; then
#TODO get seedwords from cln.backup.sh seed-import-gui [$RESULTFILE]
seedwords="$3"
seedpassword="$4"