diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-07-07 06:06:41 -1100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-07-07 06:07:41 -1100 |
commit | 88a15ebc8d317a6fd4851adb344ff944d497284c (patch) | |
tree | 36c9ea2eb936e64b0c270b1cc31c2004f0111cdb /src/wallet/rpcwallet.cpp | |
parent | 0212187fc624ea4a02fc99bc57ebd413499a9ee1 (diff) | |
parent | ea65182f033eca73c291057dacd54f8e4e809fbd (diff) | |
download | bitcoin-88a15ebc8d317a6fd4851adb344ff944d497284c.tar.xz |
Merge #13564: [wallet] loadwallet shouldn't create new wallets.
ea65182f03 [wallet] loadwallet shouldn't create new wallets. (John Newbery)
Pull request description:
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).
Tree-SHA512: 0a59fa8a33fde51a88544ad288b00e4995284fe16424f643076aaba42b8244fff362145217650ee53d518dfab7efbed4237632c34cdd3dcbbecaa9ecaab5fd7b
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c1f4c99851..b1d2532d86 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3091,6 +3091,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; |