diff --git a/src/app.h b/src/app.h index 308e3d7..cd116ab 100644 --- a/src/app.h +++ b/src/app.h @@ -182,6 +182,9 @@ public: const std::string& liteOpenError() const { return lite_open_error_; } // Show the lite send-time unlock modal (called when a spend is attempted on a locked wallet). void requestLiteUnlock() { lite_unlock_prompt_ = true; } + // Lock the lite wallet AND immediately tear down the chat session (the lite backend `lock` + // doesn't update state_.locked until the next poll, so chat secrets would otherwise linger). + bool lockLiteWallet(); // (Re)build the lite controller from current settings so a changed lite-server selection // takes effect. No-op on non-lite/unlinked builds; preserves a live wallet (see app.cpp). void rebuildLiteWallet(bool force = false); diff --git a/src/app_network.cpp b/src/app_network.cpp index 2f910e5..e2a9128 100644 --- a/src/app_network.cpp +++ b/src/app_network.cpp @@ -2660,6 +2660,25 @@ void App::ingestLiteChatMemos(const wallet::LiteWalletAppRefreshModel& model) if (!metadata.empty()) chat_service_.ingest(metadata, txTimestamps, std::time(nullptr)); } +bool App::lockLiteWallet() +{ + if (!lite_wallet_) return false; + const bool ok = lite_wallet_->lockWallet(); + if (ok) { + // Full-node App::lockWallet() sets state_.locked synchronously; the lite backend `lock` + // doesn't, and state_.locked only refreshes on the next ~2s poll. Mirror the full-node + // behavior here and tear down the chat session NOW so no decrypted store / unlocked DB key + // lingers past an explicit lock. (These chat calls are safe no-ops when chat is off/idle.) + state_.locked = true; + chat_service_.clearIdentity(); + chat_service_.store().clear(); + chat_db_.lock(); + chat_identity_provisioned_ = false; + chat_identity_unavailable_ = false; + } + return ok; +} + void App::seedChatDemoData() { if (!chat::hushChatFeatureEnabledAtBuild()) return; diff --git a/src/ui/pages/settings_page.cpp b/src/ui/pages/settings_page.cpp index fa66313..c3b4079 100644 --- a/src/ui/pages/settings_page.cpp +++ b/src/ui/pages/settings_page.cpp @@ -1818,8 +1818,9 @@ void RenderSettingsPage(App* app) { } else { ImGui::SetCursorScreenPos(ImVec2(leftX, ImGui::GetCursorScreenPos().y)); if (TactileButton(TrId("lite_lock_now", "LiteLock").c_str(), ImVec2(0, 0), S.resolveFont("button"))) { + // Route through App so the chat session is torn down immediately on lock. s_settingsState.lite_encryption_status = - app->liteWallet()->lockWallet() ? TR("lite_wallet_locked") : TR("lite_lock_failed"); + app->lockLiteWallet() ? TR("lite_wallet_locked") : TR("lite_lock_failed"); } } ImGui::SetCursorScreenPos(ImVec2(leftX, ImGui::GetCursorScreenPos().y));