Skip to content

Commit b673429

Browse files
committed
Cleanups for walletdir PR
1 parent 0d89fa0 commit b673429

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

doc/release-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Custom wallet directories
6767
The ability to specify a directory other than the default data directory in which to store
6868
wallets has been added. An existing directory can be specified using the `-walletdir=<dir>`
6969
argument. Wallets loaded via `-wallet` arguments must be in this wallet directory. Care should be taken
70-
when choosing a wallet directory location, as if it becomes unavailable during operation,
70+
when choosing a wallet directory location, as if it becomes unavailable during operation,
7171
funds may be lost.
7272

7373
Default wallet directory change

src/wallet/init.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ bool VerifyWallets()
194194
}
195195

196196
if (gArgs.IsArgSet("-walletdir") && !fs::is_directory(GetWalletDir())) {
197-
return InitError(strprintf(_("Error: Specified wallet directory \"%s\" does not exist."), gArgs.GetArg("-walletdir", "").c_str()));
197+
if (fs::exists(fs::system_complete(gArgs.GetArg("-walletdir", "")))) {
198+
return InitError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), gArgs.GetArg("-walletdir", "").c_str()));
199+
}
200+
return InitError(strprintf(_("Specified -walletdir \"%s\" does not exist"), gArgs.GetArg("-walletdir", "").c_str()));
198201
}
199202

200203
LogPrintf("Using wallet directory %s\n", GetWalletDir().string());

src/wallet/walletutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include "wallet/walletutil.h"
5+
#include <wallet/walletutil.h>
66

77
fs::path GetWalletDir()
88
{

src/wallet/walletutil.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#ifndef BITCOIN_WALLET_UTIL_H
66
#define BITCOIN_WALLET_UTIL_H
77

8-
#include "util.h"
8+
#include <chainparamsbase.h>
9+
#include <util.h>
910

1011
//! Get the path of the wallet directory.
1112
fs::path GetWalletDir();

test/functional/multiwallet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ def run_test(self):
4040
self.assert_start_raises_init_error(0, ['-wallet=w12'], 'Error loading wallet w12. -wallet filename must be a regular file.')
4141

4242
# should not initialize if the specified walletdir does not exist
43-
self.assert_start_raises_init_error(0, ['-walletdir=bad'], 'Error: Specified wallet directory "bad" does not exist.')
43+
self.assert_start_raises_init_error(0, ['-walletdir=bad'], 'Error: Specified -walletdir "bad" does not exist')
44+
# should not initialize if the specified walletdir is not a directory
45+
not_a_dir = os.path.join(wallet_dir, 'notadir')
46+
open(not_a_dir, 'a').close()
47+
self.assert_start_raises_init_error(0, ['-walletdir='+not_a_dir], 'Error: Specified -walletdir "' + not_a_dir + '" is not a directory')
4448

4549
# if wallets/ doesn't exist, datadir should be the default wallet dir
4650
wallet_dir2 = os.path.join(self.options.tmpdir, 'node0', 'regtest', 'walletdir')

0 commit comments

Comments
 (0)