From 138424a6c45a3bf2ac47f13e6ddeb4e07575d9b9 Mon Sep 17 00:00:00 2001 From: se7enz Date: Mon, 25 May 2026 16:48:01 +0200 Subject: [PATCH 1/2] Startup retry loop for `nbxplorer` connection Avoids an `arkd-wallet` crash by ensuring nbxplorer can serve RPCs before continuing with a connection. Retries 30 times at 5 second intervals for a total of 2.5 minutes, leaving the orchestrator to restart afterward. --- .../core/infrastructure/nbxplorer/service.go | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go b/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go index 10970d0b0..7fcd58f51 100644 --- a/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go +++ b/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go @@ -44,6 +44,11 @@ type nbxplorer struct { groupID string } +const ( + nbxplorerMaxRetries = 30 + nbxplorerRetryInterval = 5 * time.Second +) + func New(rawURL string) (ports.Nbxplorer, error) { rawURL = strings.TrimSuffix(rawURL, "/") @@ -67,9 +72,24 @@ func New(rawURL string) (ports.Nbxplorer, error) { groupID: "", } - status, err := svc.GetBitcoinStatus(context.Background()) - if err != nil { - return nil, fmt.Errorf("failed to connect to nbxplorer: %s", err) + var status *ports.BitcoinStatus + + for attempt := 1; attempt <= nbxplorerMaxRetries; attempt++ { + status, err = svc.GetBitcoinStatus(context.Background()) + if err == nil { + break + } + + if attempt == nbxplorerMaxRetries { + return nil, fmt.Errorf("failed to connect to nbxplorer after %d attempts: %s", nbxplorerMaxRetries, err) + } + + log.WithFields(log.Fields{ + "attempt": attempt, + "error": err.Error(), + }).Warn("nbxplorer not ready, retrying") + + time.Sleep(nbxplorerRetryInterval) } svc.minRelayTxFee = status.MinRelayTxFee From 6c964d41674cd68d104a82d8cd574b56d8ba55e0 Mon Sep 17 00:00:00 2001 From: se7enz Date: Fri, 29 May 2026 08:58:45 +0200 Subject: [PATCH 2/2] Fix nbxplorer constant assignment alignment --- pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go b/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go index 7fcd58f51..ec1eaf5b9 100644 --- a/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go +++ b/pkg/arkd-wallet/core/infrastructure/nbxplorer/service.go @@ -45,7 +45,7 @@ type nbxplorer struct { } const ( - nbxplorerMaxRetries = 30 + nbxplorerMaxRetries = 30 nbxplorerRetryInterval = 5 * time.Second )