Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets
This commit is contained in:
parent
0f08575be2
commit
008c360083
1 changed files with 29 additions and 27 deletions
|
@ -440,30 +440,40 @@ bool CWallet::Verify()
|
||||||
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
|
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
uiInterface.InitMessage(_("Verifying wallet..."));
|
SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
|
||||||
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
|
|
||||||
|
|
||||||
std::string strError;
|
uiInterface.InitMessage(_("Verifying wallet(s)..."));
|
||||||
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError))
|
|
||||||
return InitError(strError);
|
|
||||||
|
|
||||||
if (GetBoolArg("-salvagewallet", false))
|
for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
|
||||||
{
|
if (boost::filesystem::path(walletFile).filename() != walletFile) {
|
||||||
// Recover readable keypairs:
|
return InitError(_("-wallet parameter must only specify a filename (not a path)"));
|
||||||
CWallet dummyWallet;
|
} else if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) {
|
||||||
if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, CWalletDB::RecoverKeysOnlyFilter))
|
return InitError(_("Invalid characters in -wallet filename"));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string strError;
|
||||||
|
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError))
|
||||||
|
return InitError(strError);
|
||||||
|
|
||||||
|
if (GetBoolArg("-salvagewallet", false))
|
||||||
|
{
|
||||||
|
// Recover readable keypairs:
|
||||||
|
CWallet dummyWallet;
|
||||||
|
if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, CWalletDB::RecoverKeysOnlyFilter))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string strWarning;
|
||||||
|
bool dbV = CWalletDB::VerifyDatabaseFile(walletFile, GetDataDir().string(), strWarning, strError);
|
||||||
|
if (!strWarning.empty())
|
||||||
|
InitWarning(strWarning);
|
||||||
|
if (!dbV)
|
||||||
|
{
|
||||||
|
InitError(strError);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strWarning;
|
|
||||||
bool dbV = CWalletDB::VerifyDatabaseFile(walletFile, GetDataDir().string(), strWarning, strError);
|
|
||||||
if (!strWarning.empty())
|
|
||||||
InitWarning(strWarning);
|
|
||||||
if (!dbV)
|
|
||||||
{
|
|
||||||
InitError(strError);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3930,15 +3940,7 @@ bool CWallet::InitLoadWallet()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
|
|
||||||
|
|
||||||
for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
|
for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
|
||||||
if (boost::filesystem::path(walletFile).filename() != walletFile) {
|
|
||||||
return InitError(_("-wallet parameter must only specify a filename (not a path)"));
|
|
||||||
} else if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) {
|
|
||||||
return InitError(_("Invalid characters in -wallet filename"));
|
|
||||||
}
|
|
||||||
|
|
||||||
CWallet * const pwallet = CreateWalletFromFile(walletFile);
|
CWallet * const pwallet = CreateWalletFromFile(walletFile);
|
||||||
if (!pwallet) {
|
if (!pwallet) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue