mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
[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).
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user