check for CLNwalletLock and get password at start

This commit is contained in:
openoms 2021-09-20 14:44:27 +01:00
parent 6cc91f1f4d
commit 46fdf6d0a6
No known key found for this signature in database
GPG Key ID: 5BFB77609B081B65
3 changed files with 27 additions and 2 deletions

View File

@ -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

View File

@ -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
#####################################

View File

@ -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:]]')