From 46fdf6d0a6b68085ab10cfcf407a0c58baf22dbb Mon Sep 17 00:00:00 2001 From: openoms Date: Mon, 20 Sep 2021 14:44:27 +0100 Subject: [PATCH] check for CLNwalletLock and get password at start --- home.admin/00infoLCD.sh | 2 +- home.admin/00raspiblitz.sh | 6 ++++++ home.admin/config.scripts/blitz.statusscan.sh | 21 ++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index d2a5f6f3d..545be8619 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -104,7 +104,7 @@ while : # TODO: ALSO SEPARATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION # if lightning is syncing or scanning source <(sudo /home/admin/config.scripts/blitz.statusscan.sh $lightning) - if [ "${walletLocked}" == "1" ]; then + if [ "${walletLocked}" == "1" ] || [ "${CLNwalletLocked}" == "1" ]; then /home/admin/setup.scripts/eventInfoWait.sh "walletlocked" "" lcd sleep 3 continue diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 71ce1895e..d601b46b2 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -141,6 +141,12 @@ do /home/admin/config.scripts/lnd.unlock.sh fi + # CLN Wallet Unlock + if [ "${clnActive}" == "1" ] && [ "${CLNwalletLocked}" == "1" ] && [ "${state}" == "ready" ] && [ "${setupPhase}" == "done" ]; then + /home/admin/config.scripts/cln.hsmtool.sh unlock + sleep 5 + fi + ##################################### # SETUP MENU ##################################### diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 268b5843e..7f1b80f38 100755 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -277,8 +277,27 @@ if [ ${lndRunning} -eq 1 ] && [ "${LNTYPE}" == "lnd" ]; then fi # is CLN running -clnRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running) +clnStatus=$(systemctl status ${netprefix}lightningd.service 2>/dev/null) +clnRunning=$(echo "${clnStatus}" | grep -c running) echo "clnActive=${clnRunning}" +clnRestarting=$(echo "${clnStatus}" | grep -c "activating (auto-restart)") +echo "clnRestarting=${clnRestarting}" +if [ "${clnRestarting}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then + clnInfo=$($lightningcli_alias getinfo 2>&1) + + # check if locked + if [ $(echo "${clnInfo}" | grep -c "Connecting to 'lightning-rpc': Connection refused") -gt 0 ];then + echo "# CLN wallet not running yet" + clnError=$(sudo journalctl -n5 -u lightningd) + if [ $(echo "${clnError}" | grep -c 'encrypted-hsm: Could not read pass from stdin.') -gt 0 ]\ + || [ $(echo "${clnError}" | grep -c 'hsm_secret is encrypted, you need to pass the --encrypted-hsm startup option.') -gt 0 ]\ + || [ $(echo "${clnError}" | grep -c 'Wrong password for encrypted hsm_secret.') -gt 0 ]; then + echo "CLNwalletLocked=1" + else + echo "CLNwalletLocked=0" + fi + fi +fi if [ "${clnRunning}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then clnInfo=$($lightningcli_alias getinfo) clnBlockHeight=$(echo "${clnInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]')