Merge #7608: [wallet] Move hardcoded file name out of log messages
fa19b18 [wallet] Move hardcoded file name out of log messages (MarcoFalke)
This commit is contained in:
parent
5f9bfa0b6d
commit
abbbe61d0f
@ -402,7 +402,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
|
|||||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||||
}
|
}
|
||||||
if (!pwalletMain->CommitTransaction(wtxNew, reservekey, g_connman.get(), fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX))
|
if (!pwalletMain->CommitTransaction(wtxNew, reservekey, g_connman.get(), fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX))
|
||||||
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.");
|
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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue sendtoaddress(const UniValue& params, bool fHelp)
|
UniValue sendtoaddress(const UniValue& params, bool fHelp)
|
||||||
@ -1941,7 +1941,7 @@ UniValue backupwallet(const UniValue& params, bool fHelp)
|
|||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"backupwallet \"destination\"\n"
|
"backupwallet \"destination\"\n"
|
||||||
"\nSafely copies wallet.dat to destination, which can be a directory or a path with filename.\n"
|
"\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"destination\" (string) The destination directory or file\n"
|
"1. \"destination\" (string) The destination directory or file\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
|
@ -627,13 +627,14 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er
|
|||||||
CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover);
|
CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover);
|
||||||
if (r == CDBEnv::RECOVER_OK)
|
if (r == CDBEnv::RECOVER_OK)
|
||||||
{
|
{
|
||||||
warningString += strprintf(_("Warning: wallet.dat corrupt, data salvaged!"
|
warningString += strprintf(_("Warning: Wallet file corrupt, data salvaged!"
|
||||||
" Original wallet.dat saved as wallet.{timestamp}.bak in %s; if"
|
" Original %s saved as %s in %s; if"
|
||||||
" your balance or transactions are incorrect you should"
|
" your balance or transactions are incorrect you should"
|
||||||
" restore from a backup."), GetDataDir());
|
" restore from a backup."),
|
||||||
|
walletFile, "wallet.{timestamp}.bak", GetDataDir());
|
||||||
}
|
}
|
||||||
if (r == CDBEnv::RECOVER_FAIL)
|
if (r == CDBEnv::RECOVER_FAIL)
|
||||||
errorString += _("wallet.dat corrupt, salvage failed");
|
errorString += strprintf(_("%s corrupt, salvage failed"), walletFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -4357,7 +4358,7 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
|
|||||||
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
|
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
|
||||||
CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
|
CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
|
||||||
strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
|
strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
|
||||||
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet.dat on startup"));
|
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup"));
|
||||||
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), DEFAULT_SEND_FREE_TRANSACTIONS));
|
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), DEFAULT_SEND_FREE_TRANSACTIONS));
|
||||||
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
|
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
|
||||||
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));
|
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));
|
||||||
@ -4402,8 +4403,8 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
|
|||||||
CWallet *tempWallet = new CWallet(strWalletFile);
|
CWallet *tempWallet = new CWallet(strWalletFile);
|
||||||
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
|
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
|
||||||
if (nZapWalletRet != DB_LOAD_OK) {
|
if (nZapWalletRet != DB_LOAD_OK) {
|
||||||
errorString = _("Error loading wallet.dat: Wallet corrupted");
|
errorString = strprintf(_("Error loading %s: Wallet corrupted"), strWalletFile);
|
||||||
uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
|
uiInterface.InitMessage(strprintf(_("Error loading %s: Wallet corrupted"), strWalletFile));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4420,21 +4421,24 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
|
|||||||
if (nLoadWalletRet != DB_LOAD_OK)
|
if (nLoadWalletRet != DB_LOAD_OK)
|
||||||
{
|
{
|
||||||
if (nLoadWalletRet == DB_CORRUPT)
|
if (nLoadWalletRet == DB_CORRUPT)
|
||||||
errorString += _("Error loading wallet.dat: Wallet corrupted") + "\n";
|
errorString += strprintf(_("Error loading %s: Wallet corrupted"), strWalletFile) + "\n";
|
||||||
else if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
|
else if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
|
||||||
{
|
{
|
||||||
warningString += _("Error reading wallet.dat! All keys read correctly, but transaction data"
|
warningString += strprintf(_("Error reading %s! All keys read correctly, but transaction data"
|
||||||
" or address book entries might be missing or incorrect.");
|
" or address book entries might be missing or incorrect."),
|
||||||
|
strWalletFile);
|
||||||
}
|
}
|
||||||
else if (nLoadWalletRet == DB_TOO_NEW)
|
else if (nLoadWalletRet == DB_TOO_NEW)
|
||||||
errorString += strprintf(_("Error loading wallet.dat: Wallet requires newer version of %s"), _(PACKAGE_NAME)) + "\n";
|
errorString += strprintf(_("Error loading %s: Wallet requires newer version of %s"),
|
||||||
|
strWalletFile, _(PACKAGE_NAME)) +
|
||||||
|
"\n";
|
||||||
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||||
{
|
{
|
||||||
errorString += strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)) + "\n";
|
errorString += strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)) + "\n";
|
||||||
LogPrintf("%s", errorString);
|
LogPrintf("%s", errorString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
errorString += _("Error loading wallet.dat") + "\n";
|
errorString += strprintf(_("Error loading %s"), strWalletFile) + "\n";
|
||||||
|
|
||||||
if (!errorString.empty())
|
if (!errorString.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -884,16 +884,16 @@ void ThreadFlushWalletDB(const string& strFile)
|
|||||||
map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
|
map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
|
||||||
if (mi != bitdb.mapFileUseCount.end())
|
if (mi != bitdb.mapFileUseCount.end())
|
||||||
{
|
{
|
||||||
LogPrint("db", "Flushing wallet.dat\n");
|
LogPrint("db", "Flushing %s\n", strFile);
|
||||||
nLastFlushed = nWalletDBUpdated;
|
nLastFlushed = nWalletDBUpdated;
|
||||||
int64_t nStart = GetTimeMillis();
|
int64_t nStart = GetTimeMillis();
|
||||||
|
|
||||||
// Flush wallet.dat so it's self contained
|
// Flush wallet file so it's self contained
|
||||||
bitdb.CloseDb(strFile);
|
bitdb.CloseDb(strFile);
|
||||||
bitdb.CheckpointLSN(strFile);
|
bitdb.CheckpointLSN(strFile);
|
||||||
|
|
||||||
bitdb.mapFileUseCount.erase(mi++);
|
bitdb.mapFileUseCount.erase(mi++);
|
||||||
LogPrint("db", "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart);
|
LogPrint("db", "Flushed %s %dms\n", strFile, GetTimeMillis() - nStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -916,7 +916,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
|
|||||||
bitdb.CheckpointLSN(wallet.strWalletFile);
|
bitdb.CheckpointLSN(wallet.strWalletFile);
|
||||||
bitdb.mapFileUseCount.erase(wallet.strWalletFile);
|
bitdb.mapFileUseCount.erase(wallet.strWalletFile);
|
||||||
|
|
||||||
// Copy wallet.dat
|
// Copy wallet file
|
||||||
boost::filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
|
boost::filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
|
||||||
boost::filesystem::path pathDest(strDest);
|
boost::filesystem::path pathDest(strDest);
|
||||||
if (boost::filesystem::is_directory(pathDest))
|
if (boost::filesystem::is_directory(pathDest))
|
||||||
@ -928,10 +928,10 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
|
|||||||
#else
|
#else
|
||||||
boost::filesystem::copy_file(pathSrc, pathDest);
|
boost::filesystem::copy_file(pathSrc, pathDest);
|
||||||
#endif
|
#endif
|
||||||
LogPrintf("copied wallet.dat to %s\n", pathDest.string());
|
LogPrintf("copied %s to %s\n", wallet.strWalletFile, pathDest.string());
|
||||||
return true;
|
return true;
|
||||||
} catch (const boost::filesystem::filesystem_error& e) {
|
} catch (const boost::filesystem::filesystem_error& e) {
|
||||||
LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what());
|
LogPrintf("error copying %s to %s - %s\n", wallet.strWalletFile, pathDest.string(), e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1061,15 +1061,15 @@ bool AutoBackupWallet (CWallet* wallet, std::string strWalletFile, std::string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to (very carefully!) recover wallet.dat if there is a problem.
|
// Try to (very carefully!) recover wallet file if there is a problem.
|
||||||
//
|
//
|
||||||
bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKeys)
|
bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKeys)
|
||||||
{
|
{
|
||||||
// Recovery procedure:
|
// Recovery procedure:
|
||||||
// move wallet.dat to wallet.timestamp.bak
|
// move wallet file to wallet.timestamp.bak
|
||||||
// Call Salvage with fAggressive=true to
|
// Call Salvage with fAggressive=true to
|
||||||
// get as much data as possible.
|
// get as much data as possible.
|
||||||
// Rewrite salvaged data to wallet.dat
|
// Rewrite salvaged data to fresh wallet file
|
||||||
// Set -rescan so any missing transactions will be
|
// Set -rescan so any missing transactions will be
|
||||||
// found.
|
// found.
|
||||||
int64_t now = GetTime();
|
int64_t now = GetTime();
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Access to the wallet database (wallet.dat) */
|
/** Access to the wallet database */
|
||||||
class CWalletDB : public CDB
|
class CWalletDB : public CDB
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user