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 fi
# CLN Wallet Unlock # 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 /home/admin/config.scripts/cln.hsmtool.sh unlock
sleep 5 sleep 5
fi fi

View File

@@ -277,14 +277,11 @@ if [ ${lndRunning} -eq 1 ] && [ "${LNTYPE}" == "lnd" ]; then
fi fi
# is CLN running # is CLN running
clnStatus=$(systemctl status ${netprefix}lightningd.service 2>/dev/null) clnRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running)
clnRunning=$(echo "${clnStatus}" | grep -c running)
echo "clnActive=${clnRunning}" echo "clnActive=${clnRunning}"
clnRestarting=$(echo "${clnStatus}" | grep -c "activating (auto-restart)") echo "CLNwalletLocked=0"
echo "clnRestarting=${clnRestarting}" if [ "${clnRunning}" != "1" ] && [ "${LNTYPE}" == "cln" ]; then
if [ "${clnRestarting}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then
clnInfo=$($lightningcli_alias getinfo 2>&1) clnInfo=$($lightningcli_alias getinfo 2>&1)
# check if locked # check if locked
if [ $(echo "${clnInfo}" | grep -c "Connecting to 'lightning-rpc': Connection refused") -gt 0 ];then if [ $(echo "${clnInfo}" | grep -c "Connecting to 'lightning-rpc': Connection refused") -gt 0 ];then
echo "# CLN wallet not running yet" 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 '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 "${clnError}" | grep -c 'Wrong password for encrypted hsm_secret.') -gt 0 ]; then
echo "CLNwalletLocked=1" echo "CLNwalletLocked=1"
else
echo "CLNwalletLocked=0"
fi fi
fi fi
fi fi
if [ "${clnRunning}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then if [ "${clnRunning}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then
clnInfo=$($lightningcli_alias getinfo) clnInfo=$($lightningcli_alias getinfo)
clnBlockHeight=$(echo "${clnInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]') clnBlockHeight=$(echo "${clnInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]')

View File

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