Create CL wallet from seedwords before start (#2822)

This commit is contained in:
openoms 2021-12-18 22:07:37 +00:00 committed by GitHub
parent 6e2f6dfec4
commit 2704406819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 5 deletions

View file

@ -81,6 +81,9 @@ if [ "${cl}" != "${choice}" ]; then
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
echo "# Successfully installed CL on $CHAIN"
# for mainnet only
# generate wallet from seedwords
/home/admin/config.scripts/cl.hsmtool.sh new $CHAIN
else
l1="# !!! FAIL on CL on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"

View file

@ -418,11 +418,14 @@ if [ "${clNode}" != "${choice}" ]; then
if [ "${choice}" = "on" ]; then
echo "# turning ON"
/home/admin/config.scripts/cl.install.sh on mainnet
sudo /home/admin/config.scripts/cl.install.sh display-seed mainnet
# generate wallet from seedwords or just display
/home/admin/config.scripts/cl.hsmtool.sh new mainnet
if [ "${testnet}" == "on" ]; then
# no seed for testnet
/home/admin/config.scripts/cl.install.sh on testnet
fi
if [ "${signet}" == "on" ]; then
# no seed for signet
/home/admin/config.scripts/cl.install.sh on signet
fi
else

View file

@ -17,7 +17,7 @@ if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]||\
echo "cl.hsmtool.sh [new] [mainnet|testnet|signet] [?seedPassword]"
echo "cl.hsmtool.sh [new-force] [mainnet|testnet|signet] [?seedPassword]"
echo "There will be no seedPassword(passphrase) used by default"
echo "new-force will delete any old wallet and will work without dialog"
echo "new-force will backup the old wallet and will work without interaction"
echo
echo "cl.hsmtool.sh [seed] [mainnet|testnet|signet] [\"space-separated-seed-words\"] [?seedPassword]"
echo "cl.hsmtool.sh [seed-force] [mainnet|testnet|signet] [\"space-separated-seed-words\"] [?seedPassword]"
@ -165,12 +165,37 @@ if [ "$1" = "new" ] || [ "$1" = "new-force" ] || [ "$1" = "seed" ] || [ "$1" = "
# check/delete existing wallet
if [ "$1" = "new-force" ] || [ "$1" = "seed-force" ]; then
echo "# deleting any old wallet ..."
sudo rm $hsmSecretPath 2>/dev/null
if sudo ls $hsmSecretPath 2>1 1>/dev/null; then
echo "# Moving the old wallet to backup"
now=$(date +"%Y_%m_%d_%H%M%S")
sudo mv $hsmSecretPath $hsmSecretPath.backup.${now} 2>/dev/null || exit 1
fi
else
if sudo ls $hsmSecretPath 2>1 1>/dev/null; then
echo "# The hsm_secret is already present at $hsmSecretPath."
if [ ${CHAIN} = "mainnet" ]; then
if sudo ls /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info 2>1 1>/dev/null; then
echo "# There is a /home/bitcoin/.lightning/${CLNETWORK}/seedwords.info so don't create new"
# show seed
sudo /home/admin/config.scripts/cl.install.sh display-seed mainnet
exit 0
else
# there should be no hsm_secret without seedwords.info, but protect this edge-case
whiptail --title " An hsm_secret is present " \
--yes-button "New wallet" \
--no-button "Keep no seed" \
--yesno "The wallet was autogenerated by lightningd and there is no seedwords.info file.\nDo you want to generate a new wallet from seedwords?" 9 60
if [ $? -eq 0 ]; then
echo "# yes-button -> New wallet"
echo "# Moving the old wallet to backup"
now=$(date +"%Y_%m_%d_%H%M%S")
sudo mv $hsmSecretPath $hsmSecretPath.backup.${now} 2>/dev/null || exit 1
else
echo "# no-button -> Keep the hsm_secret"
exit 0
fi
fi
fi
fi
fi

View file

@ -300,6 +300,17 @@ always-use-proxy=true
sudo chown -R bitcoin:bitcoin /mnt/hdd/app-data/.lightning
sudo chown -R bitcoin:bitcoin /home/bitcoin/
## Create a wallet from seedwords for mainnet
if [ ${CHAIN} = "mainnet" ]; then
hsmSecretPath="/home/bitcoin/.lightning/${CLNETWORK}/hsm_secret"
if sudo ls $hsmSecretPath; then
echo "# $hsmSecretPath is already present"
else
echo "Create a wallet from seedwords for mainnet"
/home/admin/config.scripts/cl.hsmtool.sh new-force mainnet
fi
fi
#################
# Backup plugin #
#################