From be254ccb19af65342ca01d26d87a5e1a7848eb05 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Thu, 11 Jun 2026 20:00:00 +0800 Subject: [PATCH] accounts/usbwallet: fix De Morgan error dropping stale wallets on refresh The inner loop in refreshWallets drops cached wallets that sort before the next enumerated device or that have failed. When this drop-while logic was refactored into an early break, the condition was negated but the boolean operator was left as ||, so the negation is incomplete. The drop condition is: (URL.Cmp(url) < 0) || (failure != nil) so the break (abort dropping) condition must be its De Morgan negation: (URL.Cmp(url) >= 0) && (failure == nil) With ||, the loop breaks as soon as the front wallet is operational, even when it sorts before the current device. The stale wallet is not dropped in place, and neither the "wrap new wallet" nor the "keep matching wallet" branch matches, so the still-present device is silently skipped for that refresh cycle (no WalletArrived) and is only re-added on a later refresh. Switch the operator to && so the break condition correctly mirrors the intended drop semantics. --- accounts/usbwallet/hub.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/usbwallet/hub.go b/accounts/usbwallet/hub.go index cfa844b345..47c53a5358 100644 --- a/accounts/usbwallet/hub.go +++ b/accounts/usbwallet/hub.go @@ -220,7 +220,7 @@ func (hub *Hub) refreshWallets() { for len(hub.wallets) > 0 { // Abort if we're past the current device and found an operational one _, failure := hub.wallets[0].Status() - if hub.wallets[0].URL().Cmp(url) >= 0 || failure == nil { + if hub.wallets[0].URL().Cmp(url) >= 0 && failure == nil { break } // Drop the stale and failed devices