diff options
-rw-r--r-- | doc/release-notes.md | 2 | ||||
-rw-r--r-- | src/wallet/init.cpp | 5 | ||||
-rw-r--r-- | src/wallet/walletutil.cpp | 2 | ||||
-rw-r--r-- | src/wallet/walletutil.h | 3 | ||||
-rwxr-xr-x | test/functional/multiwallet.py | 6 |
5 files changed, 13 insertions, 5 deletions
diff --git a/doc/release-notes.md b/doc/release-notes.md index 32f1bef62c..5456965bdb 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -67,7 +67,7 @@ Custom wallet directories The ability to specify a directory other than the default data directory in which to store wallets has been added. An existing directory can be specified using the `-walletdir=<dir>` argument. Wallets loaded via `-wallet` arguments must be in this wallet directory. Care should be taken -when choosing a wallet directory location, as if it becomes unavailable during operation, +when choosing a wallet directory location, as if it becomes unavailable during operation, funds may be lost. Default wallet directory change diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 67c46df87d..788bac2a46 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -194,7 +194,10 @@ bool VerifyWallets() } if (gArgs.IsArgSet("-walletdir") && !fs::is_directory(GetWalletDir())) { - return InitError(strprintf(_("Error: Specified wallet directory \"%s\" does not exist."), gArgs.GetArg("-walletdir", "").c_str())); + if (fs::exists(fs::system_complete(gArgs.GetArg("-walletdir", "")))) { + return InitError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), gArgs.GetArg("-walletdir", "").c_str())); + } + return InitError(strprintf(_("Specified -walletdir \"%s\" does not exist"), gArgs.GetArg("-walletdir", "").c_str())); } LogPrintf("Using wallet directory %s\n", GetWalletDir().string()); diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index fbb5215a51..f15e5de1e2 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "wallet/walletutil.h" +#include <wallet/walletutil.h> fs::path GetWalletDir() { diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index a94f286a44..50ff736402 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -5,7 +5,8 @@ #ifndef BITCOIN_WALLET_UTIL_H #define BITCOIN_WALLET_UTIL_H -#include "util.h" +#include <chainparamsbase.h> +#include <util.h> //! Get the path of the wallet directory. fs::path GetWalletDir(); diff --git a/test/functional/multiwallet.py b/test/functional/multiwallet.py index 4a721d1109..ceeb6f7cbd 100755 --- a/test/functional/multiwallet.py +++ b/test/functional/multiwallet.py @@ -40,7 +40,11 @@ class MultiWalletTest(BitcoinTestFramework): self.assert_start_raises_init_error(0, ['-wallet=w12'], 'Error loading wallet w12. -wallet filename must be a regular file.') # should not initialize if the specified walletdir does not exist - self.assert_start_raises_init_error(0, ['-walletdir=bad'], 'Error: Specified wallet directory "bad" does not exist.') + self.assert_start_raises_init_error(0, ['-walletdir=bad'], 'Error: Specified -walletdir "bad" does not exist') + # should not initialize if the specified walletdir is not a directory + not_a_dir = os.path.join(wallet_dir, 'notadir') + open(not_a_dir, 'a').close() + self.assert_start_raises_init_error(0, ['-walletdir='+not_a_dir], 'Error: Specified -walletdir "' + not_a_dir + '" is not a directory') # if wallets/ doesn't exist, datadir should be the default wallet dir wallet_dir2 = os.path.join(self.options.tmpdir, 'node0', 'regtest', 'walletdir') |