fix(lite): surface auto-open failures instead of a silent disconnected spinner

The startup auto-open of an existing lite wallet discarded openWallet()'s result,
so when initialize_existing failed (e.g. the lightwalletd server is unreachable)
the UI just showed a "disconnected" spinner with no reason — and DEBUG_LOGF is
compiled out of release builds, so there was no way to see why. Capture the
failure: store the reason, show it in the Network tab status line (in place of
"no wallet open"), and raise a notification. Cleared once a wallet opens.

This doesn't change open behaviour — it makes a stuck open diagnosable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 15:39:22 -05:00
parent 142a6826af
commit 6531d0c4d2
3 changed files with 26 additions and 5 deletions

View File

@@ -479,7 +479,18 @@ void App::update()
if (!lite_autoopen_done_) {
lite_autoopen_done_ = true;
if (!lite_wallet_->walletOpen() && lite_wallet_->walletExists()) {
lite_wallet_->openWallet(wallet::LiteWalletOpenRequest{});
const auto openResult = lite_wallet_->openWallet(wallet::LiteWalletOpenRequest{});
// Surface why an existing wallet failed to open (e.g. the lightwalletd server
// is unreachable) — otherwise the UI just shows a silent "disconnected" spinner.
if (!openResult.ok && !openResult.walletReady) {
lite_open_error_ = !openResult.error.empty() ? openResult.error
: (!openResult.status.message.empty()
? openResult.status.message
: "Could not open the wallet");
DEBUG_LOGF("[Lite] auto-open failed: %s\n", lite_open_error_.c_str());
ui::Notifications::instance().error(
std::string("Wallet open failed: ") + lite_open_error_, 8.0f);
}
}
}
@@ -488,6 +499,7 @@ void App::update()
// A wallet is open only after a successful backend init against the lite server, so this
// is a non-blocking proxy for "lite backend operational".
state_.connected = lite_wallet_->walletOpen();
if (state_.connected) lite_open_error_.clear(); // opened successfully — clear any prior error
// Suppress the status bar's full-node connection-detail line in lite ("" and "Connected"
// are both hidden); the connected/no-wallet indicator + sync status convey lite state.
connection_status_ = state_.connected ? "Connected" : "";