Skip to content

Commit fa19b18

Browse files
author
MarcoFalke
committed
[wallet] Move hardcoded file name out of log messages
1 parent c15eb28 commit fa19b18

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
394394
throw JSONRPCError(RPC_WALLET_ERROR, strError);
395395
}
396396
if (!pwalletMain->CommitTransaction(wtxNew, reservekey))
397-
throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
397+
throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of the wallet and coins were spent in the copy but not marked as spent here.");
398398
}
399399

400400
UniValue sendtoaddress(const UniValue& params, bool fHelp)
@@ -1827,7 +1827,7 @@ UniValue backupwallet(const UniValue& params, bool fHelp)
18271827
if (fHelp || params.size() != 1)
18281828
throw runtime_error(
18291829
"backupwallet \"destination\"\n"
1830-
"\nSafely copies wallet.dat to destination, which can be a directory or a path with filename.\n"
1830+
"\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n"
18311831
"\nArguments:\n"
18321832
"1. \"destination\" (string) The destination directory or file\n"
18331833
"\nExamples:\n"

src/wallet/wallet.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,14 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er
399399
CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover);
400400
if (r == CDBEnv::RECOVER_OK)
401401
{
402-
warningString += strprintf(_("Warning: wallet.dat corrupt, data salvaged!"
403-
" Original wallet.dat saved as wallet.{timestamp}.bak in %s; if"
404-
" your balance or transactions are incorrect you should"
405-
" restore from a backup."), GetDataDir());
402+
warningString += strprintf(_("Warning: Wallet file corrupt, data salvaged!"
403+
" Original %s saved as %s in %s; if"
404+
" your balance or transactions are incorrect you should"
405+
" restore from a backup."),
406+
walletFile, "wallet.{timestamp}.bak", GetDataDir());
406407
}
407408
if (r == CDBEnv::RECOVER_FAIL)
408-
errorString += _("wallet.dat corrupt, salvage failed");
409+
errorString += strprintf(_("%s corrupt, salvage failed"), walletFile);
409410
}
410411

411412
return true;
@@ -2968,7 +2969,7 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
29682969
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
29692970
CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
29702971
strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
2971-
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet.dat on startup"));
2972+
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup"));
29722973
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), DEFAULT_SEND_FREE_TRANSACTIONS));
29732974
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
29742975
strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
@@ -3002,8 +3003,8 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30023003
CWallet *tempWallet = new CWallet(strWalletFile);
30033004
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
30043005
if (nZapWalletRet != DB_LOAD_OK) {
3005-
errorString = _("Error loading wallet.dat: Wallet corrupted");
3006-
uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
3006+
errorString = strprintf(_("Error loading %s: Wallet corrupted"), strWalletFile);
3007+
uiInterface.InitMessage(strprintf(_("Error loading %s: Wallet corrupted"), strWalletFile));
30073008
return NULL;
30083009
}
30093010

@@ -3020,21 +3021,24 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30203021
if (nLoadWalletRet != DB_LOAD_OK)
30213022
{
30223023
if (nLoadWalletRet == DB_CORRUPT)
3023-
errorString += _("Error loading wallet.dat: Wallet corrupted") + "\n";
3024+
errorString += strprintf(_("Error loading %s: Wallet corrupted"), strWalletFile) + "\n";
30243025
else if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
30253026
{
3026-
warningString += _("Error reading wallet.dat! All keys read correctly, but transaction data"
3027-
" or address book entries might be missing or incorrect.");
3027+
warningString += strprintf(_("Error reading %s! All keys read correctly, but transaction data"
3028+
" or address book entries might be missing or incorrect."),
3029+
strWalletFile);
30283030
}
30293031
else if (nLoadWalletRet == DB_TOO_NEW)
3030-
errorString += strprintf(_("Error loading wallet.dat: Wallet requires newer version of %s"), _(PACKAGE_NAME)) + "\n";
3032+
errorString += strprintf(_("Error loading %s: Wallet requires newer version of %s"),
3033+
strWalletFile, _(PACKAGE_NAME)) +
3034+
"\n";
30313035
else if (nLoadWalletRet == DB_NEED_REWRITE)
30323036
{
30333037
errorString += strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)) + "\n";
30343038
LogPrintf("%s", errorString);
30353039
}
30363040
else
3037-
errorString += _("Error loading wallet.dat") + "\n";
3041+
errorString += strprintf(_("Error loading %s"), strWalletFile) + "\n";
30383042

30393043
if (!errorString.empty())
30403044
return NULL;

src/wallet/walletdb.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -847,16 +847,16 @@ void ThreadFlushWalletDB(const string& strFile)
847847
map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
848848
if (mi != bitdb.mapFileUseCount.end())
849849
{
850-
LogPrint("db", "Flushing wallet.dat\n");
850+
LogPrint("db", "Flushing %s\n", strFile);
851851
nLastFlushed = nWalletDBUpdated;
852852
int64_t nStart = GetTimeMillis();
853853

854-
// Flush wallet.dat so it's self contained
854+
// Flush wallet file so it's self contained
855855
bitdb.CloseDb(strFile);
856856
bitdb.CheckpointLSN(strFile);
857857

858858
bitdb.mapFileUseCount.erase(mi++);
859-
LogPrint("db", "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart);
859+
LogPrint("db", "Flushed %s %dms\n", strFile, GetTimeMillis() - nStart);
860860
}
861861
}
862862
}
@@ -879,7 +879,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
879879
bitdb.CheckpointLSN(wallet.strWalletFile);
880880
bitdb.mapFileUseCount.erase(wallet.strWalletFile);
881881

882-
// Copy wallet.dat
882+
// Copy wallet file
883883
boost::filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
884884
boost::filesystem::path pathDest(strDest);
885885
if (boost::filesystem::is_directory(pathDest))
@@ -891,10 +891,10 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
891891
#else
892892
boost::filesystem::copy_file(pathSrc, pathDest);
893893
#endif
894-
LogPrintf("copied wallet.dat to %s\n", pathDest.string());
894+
LogPrintf("copied %s to %s\n", wallet.strWalletFile, pathDest.string());
895895
return true;
896896
} catch (const boost::filesystem::filesystem_error& e) {
897-
LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what());
897+
LogPrintf("error copying %s to %s - %s\n", wallet.strWalletFile, pathDest.string(), e.what());
898898
return false;
899899
}
900900
}
@@ -905,15 +905,15 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
905905
}
906906

907907
//
908-
// Try to (very carefully!) recover wallet.dat if there is a problem.
908+
// Try to (very carefully!) recover wallet file if there is a problem.
909909
//
910910
bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKeys)
911911
{
912912
// Recovery procedure:
913-
// move wallet.dat to wallet.timestamp.bak
913+
// move wallet file to wallet.timestamp.bak
914914
// Call Salvage with fAggressive=true to
915915
// get as much data as possible.
916-
// Rewrite salvaged data to wallet.dat
916+
// Rewrite salvaged data to fresh wallet file
917917
// Set -rescan so any missing transactions will be
918918
// found.
919919
int64_t now = GetTime();

src/wallet/walletdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class CKeyMetadata
7373
}
7474
};
7575

76-
/** Access to the wallet database (wallet.dat) */
76+
/** Access to the wallet database */
7777
class CWalletDB : public CDB
7878
{
7979
public:

0 commit comments

Comments
 (0)