Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,126 Lines • ▼ Show 20 Lines | if (!location.Exists()) { | ||||
if (fs::symlink_status(wallet_dat_file).type() == fs::file_not_found) { | if (fs::symlink_status(wallet_dat_file).type() == fs::file_not_found) { | ||||
throw JSONRPCError(RPC_WALLET_NOT_FOUND, | throw JSONRPCError(RPC_WALLET_NOT_FOUND, | ||||
"Directory " + location.GetName() + | "Directory " + location.GetName() + | ||||
" does not contain a wallet.dat file."); | " does not contain a wallet.dat file."); | ||||
} | } | ||||
} | } | ||||
std::string error, warning; | std::string error, warning; | ||||
std::shared_ptr<CWallet> const wallet = LoadWallet( | std::shared_ptr<CWallet> const wallet = | ||||
chainParams, *g_rpc_interfaces->chain, location, error, warning); | LoadWallet(chainParams, *g_rpc_node->chain, location, error, warning); | ||||
if (!wallet) { | if (!wallet) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, error); | throw JSONRPCError(RPC_WALLET_ERROR, error); | ||||
} | } | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("name", wallet->GetName()); | obj.pushKV("name", wallet->GetName()); | ||||
obj.pushKV("warning", warning); | obj.pushKV("warning", warning); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static UniValue createwallet(const Config &config, | ||||
WalletLocation location(request.params[0].get_str()); | WalletLocation location(request.params[0].get_str()); | ||||
if (location.Exists()) { | if (location.Exists()) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Wallet " + location.GetName() + " already exists."); | "Wallet " + location.GetName() + " already exists."); | ||||
} | } | ||||
// Wallet::Verify will check if we're trying to create a wallet with a | // Wallet::Verify will check if we're trying to create a wallet with a | ||||
// duplicate name. | // duplicate name. | ||||
if (!CWallet::Verify(chainParams, *g_rpc_interfaces->chain, location, false, | if (!CWallet::Verify(chainParams, *g_rpc_node->chain, location, false, | ||||
error, warning)) { | error, warning)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Wallet file verification failed: " + error); | "Wallet file verification failed: " + error); | ||||
} | } | ||||
std::shared_ptr<CWallet> const wallet = CWallet::CreateWalletFromFile( | std::shared_ptr<CWallet> const wallet = CWallet::CreateWalletFromFile( | ||||
chainParams, *g_rpc_interfaces->chain, location, flags); | chainParams, *g_rpc_node->chain, location, flags); | ||||
if (!wallet) { | if (!wallet) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet creation failed."); | throw JSONRPCError(RPC_WALLET_ERROR, "Wallet creation failed."); | ||||
} | } | ||||
AddWallet(wallet); | AddWallet(wallet); | ||||
wallet->postInitProcess(); | wallet->postInitProcess(); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
▲ Show 20 Lines • Show All 1,658 Lines • Show Last 20 Lines |