cln improve wallet unlock on start

This commit is contained in:
openoms
2021-09-20 15:33:27 +01:00
parent e776be037f
commit 4e9660c33d
3 changed files with 6 additions and 10 deletions

View File

@@ -142,7 +142,7 @@ do
fi
# CLN Wallet Unlock
if [ "${clnActive}" == "1" ] && [ "${CLNwalletLocked}" == "1" ] && [ "${state}" == "ready" ] && [ "${setupPhase}" == "done" ]; then
if [ "${CLNwalletLocked}" == "1" ] && [ "${state}" == "ready" ] && [ "${setupPhase}" == "done" ]; then
/home/admin/config.scripts/cln.hsmtool.sh unlock
sleep 5
fi

View File

@@ -277,14 +277,11 @@ if [ ${lndRunning} -eq 1 ] && [ "${LNTYPE}" == "lnd" ]; then
fi
# is CLN running
clnStatus=$(systemctl status ${netprefix}lightningd.service 2>/dev/null)
clnRunning=$(echo "${clnStatus}" | grep -c running)
clnRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running)
echo "clnActive=${clnRunning}"
clnRestarting=$(echo "${clnStatus}" | grep -c "activating (auto-restart)")
echo "clnRestarting=${clnRestarting}"
if [ "${clnRestarting}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then
echo "CLNwalletLocked=0"
if [ "${clnRunning}" != "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"
@@ -293,11 +290,10 @@ if [ "${clnRestarting}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then
|| [ $(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:]]')

View File

@@ -280,7 +280,7 @@ elif [ "$1" = "unlock" ]; then
exit 1
fi
echo "# Waiting to unlock wallet ... "
sleep 5
sleep 15
attempt=$((attempt+1))
done
echo "# Ok the ${netprefix}lightningd wallet is unlocked"