From 637a58d8264abb9a7cc9c535858a66c1844e84d9 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Thu, 29 Jul 2021 20:26:34 +0200 Subject: [PATCH] lnd: improve waiting for active RPC server - Simplify - Add comment - Avoid the unneeded default call to sleep --- modules/lnd.nix | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/lnd.nix b/modules/lnd.nix index 633bb63..cf5fa9c 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -238,13 +238,8 @@ in { -d "{\"wallet_password\": \"$(cat ${secretsDir}/lnd-wallet-password | tr -d '\n' | base64 -w0)\"}" \ ${restUrl}/unlockwallet fi - state="" - while [ "$state" != "RPC_ACTIVE" ]; do - state=$(${curl} \ - -d '{}' \ - -X POST \ - ${restUrl}/state |\ - ${pkgs.jq}/bin/jq -r '.state') + # Wait until the wallet has been unlocked and RPC is fully active + while [[ $(${curl} -d '{}' -X POST ${restUrl}/state | ${pkgs.jq}/bin/jq -r '.state') != RPC_ACTIVE ]]; do sleep 0.1 done '')