From ae81fa37123730982c4e054d7433c9d0c944a373 Mon Sep 17 00:00:00 2001 From: Bitflash Date: Sat, 1 Aug 2026 14:48:12 -0300 Subject: wallet: keep the default backup out of the directory it protects (#90) Two follow-ups to #89. The default backup path was inside the data directory -- same disk, same folder the README says to copy wholesale, same folder the user eventually deletes, which is the moment the backup was for. It now defaults to the home directory and the dialog says so when a path under the data directory is chosen anyway. And nLastWalletBackup was written by the GUI, so anyone backing up with /backupwallet -- the method the README documents first -- was told forever that they had never backed up. BackupWallet records it now, so both paths count. --- src/db.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/db.cpp') diff --git a/src/db.cpp b/src/db.cpp index 7763af8..d482c5a 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -834,6 +834,15 @@ bool BackupWallet(const string& strDest) { return error("BackupWallet() : %s\n", e.what()); } } + // Recorded here rather than by whoever called, so that a backup taken with + // /backupwallet counts as much as one taken from the GUI. When the GUI + // wrote this itself, anyone following the README -- which documents the + // command line first -- was told forever that they had never backed up. + // Outside the cs_db block above: this opens the wallet for writing, and + // there is no reason to do that while holding the database lock. + try { CWalletDB().WriteSetting("nLastWalletBackup", (int64)GetTime()); } + catch (...) { } // the backup is written; failing to note it is not fatal + printf("BackupWallet() : wrote %s\n", strDest.c_str()); return true; } -- cgit v1.2.3