From f58d009703a5564eb1561bb6edce96c10213ec61 Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 16 Jun 2026 11:36:58 -0500 Subject: [PATCH] fix(lite): show real block height when synced (was 0) The lite status bar showed "blocks: 0" once fully synced. The backend's `syncstatus` only includes synced_blocks/total_blocks WHILE actively scanning; at rest it returns just {"syncing":"false"}, so the parsed syncedBlocks was 0 and became state.sync.blocks. On the synced refresh path, additionally query the backend `height` command (wallet last-scanned height, a fast local read) and use it as the synced height/tip, so the block count is correct at rest. Co-Authored-By: Claude Opus 4.8 --- src/wallet/lite_wallet_controller.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/wallet/lite_wallet_controller.cpp b/src/wallet/lite_wallet_controller.cpp index bf79817..23cf564 100644 --- a/src/wallet/lite_wallet_controller.cpp +++ b/src/wallet/lite_wallet_controller.cpp @@ -687,6 +687,29 @@ std::optional LiteWalletController::refreshModel() if (!mapped.ok) return std::nullopt; auto model = mapped.model; applyEncryption(model); + + // `syncstatus` only reports synced_blocks/total_blocks WHILE actively scanning; once idle it + // returns just {"syncing":"false"}, so the mapped walletHeight is 0 and the status bar showed + // "blocks: 0" when fully synced. Query the wallet's last-scanned height (a fast local read) and + // surface it as the synced height/tip so the block count is correct at rest. + if (bridge_) { + const auto h = bridge_->execute("height", ""); + if (h.ok) { + try { + const auto j = nlohmann::json::parse(h.value); + if (j.is_object() && j.contains("height") && j["height"].is_number_unsigned()) { + const unsigned long long height = j["height"].get(); + if (height > 0) { + model.hasSyncStatus = true; + model.sync.walletHeight = height; + model.sync.chainHeight = height; // synced: wallet height == chain tip + model.sync.complete = true; + model.sync.progress = 1.0; + } + } + } catch (...) { /* leave the mapped sync fields as-is */ } + } + } return model; }