Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,379 Lines • ▼ Show 20 Lines | UniValue loadwallet(const Config &config, const JSONRPCRequest &request) { | ||||
std::string wallet_file = request.params[0].get_str(); | std::string wallet_file = request.params[0].get_str(); | ||||
std::string error; | std::string error; | ||||
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, | throw JSONRPCError(RPC_WALLET_NOT_FOUND, | ||||
"Wallet " + wallet_file + " 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; | ||||
if (!CWallet::Verify(chainParams, wallet_file, false, error, warning)) { | if (!CWallet::Verify(chainParams, wallet_file, false, error, warning)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Wallet file verification failed: " + error); | "Wallet file verification failed: " + error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,177 Lines • Show Last 20 Lines |