Browse Source

Cleanups for walletdir PR

0.16
MeshCollider 7 years ago
parent
commit
b67342906c
  1. 2
      doc/release-notes.md
  2. 5
      src/wallet/init.cpp
  3. 2
      src/wallet/walletutil.cpp
  4. 3
      src/wallet/walletutil.h
  5. 6
      test/functional/multiwallet.py

2
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 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>` 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 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. funds may be lost.
Default wallet directory change Default wallet directory change

5
src/wallet/init.cpp

@ -194,7 +194,10 @@ bool VerifyWallets()
} }
if (gArgs.IsArgSet("-walletdir") && !fs::is_directory(GetWalletDir())) { 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()); LogPrintf("Using wallet directory %s\n", GetWalletDir().string());

2
src/wallet/walletutil.cpp

@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "wallet/walletutil.h" #include <wallet/walletutil.h>
fs::path GetWalletDir() fs::path GetWalletDir()
{ {

3
src/wallet/walletutil.h

@ -5,7 +5,8 @@
#ifndef BITCOIN_WALLET_UTIL_H #ifndef BITCOIN_WALLET_UTIL_H
#define 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. //! Get the path of the wallet directory.
fs::path GetWalletDir(); fs::path GetWalletDir();

6
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.') 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 # 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 # if wallets/ doesn't exist, datadir should be the default wallet dir
wallet_dir2 = os.path.join(self.options.tmpdir, 'node0', 'regtest', 'walletdir') wallet_dir2 = os.path.join(self.options.tmpdir, 'node0', 'regtest', 'walletdir')

Loading…
Cancel
Save