mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
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 Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
parent
0891d75340
commit
fafa767e57
@ -2916,6 +2916,12 @@ UniValue loadwallet(const JSONRPCRequest& request)
|
|||||||
fs::path wallet_path = fs::absolute(wallet_file, GetWalletDir());
|
fs::path wallet_path = fs::absolute(wallet_file, GetWalletDir());
|
||||||
if (fs::symlink_status(wallet_path).type() == fs::file_not_found) {
|
if (fs::symlink_status(wallet_path).type() == fs::file_not_found) {
|
||||||
throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Wallet " + wallet_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;
|
std::string warning;
|
||||||
|
@ -184,5 +184,9 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
# Fail to load if wallet file is a symlink
|
# Fail to load if wallet file is a symlink
|
||||||
assert_raises_rpc_error(-4, "Wallet file verification failed: Invalid -wallet path 'w8_symlink'", self.nodes[0].loadwallet, 'w8_symlink')
|
assert_raises_rpc_error(-4, "Wallet file verification failed: Invalid -wallet path 'w8_symlink'", self.nodes[0].loadwallet, 'w8_symlink')
|
||||||
|
|
||||||
|
# Fail to load if a directory is specified that doesn't contain a wallet
|
||||||
|
os.mkdir(wallet_dir('empty_wallet_dir'))
|
||||||
|
assert_raises_rpc_error(-18, "Directory empty_wallet_dir does not contain a wallet.dat file", self.nodes[0].loadwallet, 'empty_wallet_dir')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
MultiWalletTest().main()
|
MultiWalletTest().main()
|
||||||
|
Loading…
Reference in New Issue
Block a user