From 7daf5e20d9c49179351041b540875db16212d9f4 Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Mon, 22 Jun 2026 10:09:23 +0900 Subject: [PATCH 1/3] Improve reliability of wait_and_check_bitcoind Changelog-Fixed: Fixed spurious bitcoind startup failures by retrying bitcoin-cli -rpcwait checks when RPC briefly fails. --- plugins/bcli.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/bcli.c b/plugins/bcli.c index 67271bb0e9db..4a981a25af68 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -780,11 +780,21 @@ static void wait_and_check_bitcoind(struct plugin *p) { struct bcli_result *res; const char **cmd; + int i; /* Special case: -rpcwait flags go on command line, not stdin */ - cmd = gather_args(bitcoind, NULL, "-rpcwait", "-rpcwaittimeout=30", + /* We try 30 times one second rather than one time one second, because + we have seen cases bitcoind becomes available, but rpcwait still just hang + needlessly. */ + cmd = gather_args(bitcoind, NULL, "-rpcwait", "-rpcwaittimeout=1", "getnetworkinfo", NULL); - res = execute_bitcoin_cli(bitcoind, p, cmd, NULL); + for (i = 0; i < 30; i++) { + res = execute_bitcoin_cli(bitcoind, p, cmd, NULL); + if (res->exitstatus != 1) + break; + if (i != 29) + tal_free(res); + } if (res->exitstatus == 1) bitcoind_failure(p, From 8db87f1f45036493890606af10500deea8b83fb2 Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Tue, 30 Jun 2026 11:42:56 +0900 Subject: [PATCH 2/3] Update plugins/bcli.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Níckolas Goline --- plugins/bcli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bcli.c b/plugins/bcli.c index 4a981a25af68..e2b605d748c4 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -788,12 +788,12 @@ static void wait_and_check_bitcoind(struct plugin *p) needlessly. */ cmd = gather_args(bitcoind, NULL, "-rpcwait", "-rpcwaittimeout=1", "getnetworkinfo", NULL); + res = NULL; for (i = 0; i < 30; i++) { + tal_free(res); /* NULL-safe; frees previous attempt */ res = execute_bitcoin_cli(bitcoind, p, cmd, NULL); if (res->exitstatus != 1) break; - if (i != 29) - tal_free(res); } if (res->exitstatus == 1) From b0cf9fd44aca7c932da02cd9fb8700f3e0e26b04 Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Tue, 30 Jun 2026 11:43:27 +0900 Subject: [PATCH 3/3] Update plugins/bcli.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Níckolas Goline --- plugins/bcli.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/bcli.c b/plugins/bcli.c index e2b605d748c4..1b3af2b13388 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -783,9 +783,10 @@ static void wait_and_check_bitcoind(struct plugin *p) int i; /* Special case: -rpcwait flags go on command line, not stdin */ - /* We try 30 times one second rather than one time one second, because - we have seen cases bitcoind becomes available, but rpcwait still just hang - needlessly. */ + /* We try 30 times one second rather than one time thirty seconds, because + * we have seen cases bitcoind becomes available, but rpcwait still just hangs + * needlessly. + */ cmd = gather_args(bitcoind, NULL, "-rpcwait", "-rpcwaittimeout=1", "getnetworkinfo", NULL); res = NULL;