Browse Source

Cleanups for walletdir PR

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

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