aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <[email protected]>2017-07-27 00:56:30 +0100
committerJoão Barbosa <[email protected]>2017-07-28 11:23:42 +0100
commit3ef77a0c1288df524fdf0c90ca70c986f473b787 (patch)
tree8a1a1d39c81ee168e32ff2ffc6a0a7fc81cdcc1d /src/wallet/wallet.cpp
parentMerge #10931: Fix misleading "Method not found" multiwallet errors (diff)
downloaddiscoin-3ef77a0c1288df524fdf0c90ca70c986f473b787.tar.xz
discoin-3ef77a0c1288df524fdf0c90ca70c986f473b787.zip
Reject duplicate wallet filenames
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 3e9c531f0..ccf5353eb 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -468,13 +468,24 @@ bool CWallet::Verify()
uiInterface.InitMessage(_("Verifying wallet(s)..."));
+ // Keep track of each wallet absolute path to detect duplicates.
+ std::set<fs::path> wallet_paths;
+
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) {
+ }
+
+ if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) {
return InitError(_("Invalid characters in -wallet filename"));
}
+ fs::path wallet_path = fs::absolute(walletFile, GetDataDir());
+
+ if (!wallet_paths.insert(wallet_path).second) {
+ return InitError(_("Duplicate -wallet filename"));
+ }
+
std::string strError;
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError)) {
return InitError(strError);