aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2017-03-09 23:45:58 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2017-06-06 21:17:09 +0000
commit008c3600834d42a98d4f0838e9bedc873102fe73 (patch)
tree6e080ebf943133ea6ef67ab593b6551da623026c /src/wallet
parent0f08575be2c6016c2c920e2b5b994e467576857d (diff)
downloadbitcoin-008c3600834d42a98d4f0838e9bedc873102fe73.tar.xz
Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet.cpp56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 241aaffcef..f4ff5f8363 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -440,30 +440,40 @@ bool CWallet::Verify()
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true;
- uiInterface.InitMessage(_("Verifying wallet..."));
- std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
+ SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
- std::string strError;
- if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError))
- return InitError(strError);
+ uiInterface.InitMessage(_("Verifying wallet(s)..."));
- if (GetBoolArg("-salvagewallet", false))
- {
- // Recover readable keypairs:
- CWallet dummyWallet;
- if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, CWalletDB::RecoverKeysOnlyFilter))
+ 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"));
+ }
+
+ 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;
+ }
}
- 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;
}
@@ -3930,15 +3940,7 @@ bool CWallet::InitLoadWallet()
return true;
}
- SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
-
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);
if (!pwallet) {
return false;