From 0d9908019d6639a13b87eebecf41077d433b4433 Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 7 Jul 2026 17:08:29 -0500 Subject: [PATCH] fix(wallet): use localtime_s on Windows for the migration backup timestamp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit beginAdoptSeedWallet used POSIX localtime_r for its thread-safe timestamp (added in the Phase 2 review), which mingw/Windows lacks — it broke the Windows cross-compile. Guard it: localtime_s on _WIN32, localtime_r elsewhere. Latent since the Phase 2 commit (Linux-only builds didn't catch it). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app_network.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app_network.cpp b/src/app_network.cpp index f2ce688..192e9bb 100644 --- a/src/app_network.cpp +++ b/src/app_network.cpp @@ -3022,7 +3022,12 @@ void App::beginAdoptSeedWallet() const std::string legacy = datadir + "/wallet.dat"; const std::string newWallet = base + "/DRAGONX/wallet.dat"; std::time_t t = std::time(nullptr); - std::tm tmv{}; localtime_r(&t, &tmv); // thread-safe (the UI thread also uses localtime) + std::tm tmv{}; // thread-safe local time (the UI thread also uses localtime) +#ifdef _WIN32 + localtime_s(&tmv, &t); +#else + localtime_r(&t, &tmv); +#endif char ts[32]; std::strftime(ts, sizeof(ts), "%Y%m%d-%H%M%S", &tmv); const std::string backup = legacy + ".legacy-migrated-" + ts + ".bak"; if (!fs::exists(newWallet)) {