aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2018-06-28 13:36:28 -0400
committerJohn Newbery <john@johnnewbery.com>2018-06-28 13:37:44 -0400
commitea65182f033eca73c291057dacd54f8e4e809fbd (patch)
tree08c1bf08e151037ce8a35f5eefa0665b7ae72719 /src
parentd96bdd78307bc5469cb8a4d5ca0e6cbc21fe4073 (diff)
[wallet] loadwallet shouldn't create new wallets.
A bug in the initial implementation of loadwallet meant that if the arguement was a directory that didn't contain a wallet.dat file, a new wallet would be created in that directory. Fix that so that if a directory is passed in, it must contain a wallet.dat file. Bug reported by promag (João Barbosa).
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpcwallet.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index bc381d3cda..9576d1a79f 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -3092,6 +3092,12 @@ static UniValue loadwallet(const JSONRPCRequest& request)
fs::path wallet_path = fs::absolute(wallet_file, GetWalletDir());
if (fs::symlink_status(wallet_path).type() == fs::file_not_found) {
throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Wallet " + wallet_file + " not found.");
+ } else if (fs::is_directory(wallet_path)) {
+ // The given filename is a directory. Check that there's a wallet.dat file.
+ fs::path wallet_dat_file = wallet_path / "wallet.dat";
+ if (fs::symlink_status(wallet_dat_file).type() == fs::file_not_found) {
+ throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Directory " + wallet_file + " does not contain a wallet.dat file.");
+ }
}
std::string warning;