fix(wallet): use localtime_s on Windows for the migration backup timestamp

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) <noreply@anthropic.com>
This commit is contained in:
2026-07-07 17:08:29 -05:00
parent a86cb8f0f3
commit 0d9908019d

View File

@@ -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)) {