Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,090 Lines • ▼ Show 20 Lines | if (!location.Exists()) { | ||||
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 = | std::shared_ptr<CWallet> const wallet = | ||||
LoadWallet(chainParams, *g_rpc_node->chain, location, error, warning); | LoadWallet(chainParams, *g_rpc_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 50 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_node->chain, location, false, | if (!CWallet::Verify(chainParams, *g_rpc_chain, location, false, error, | ||||
error, warning)) { | warning)) { | ||||
deadalnix: This isn't in the original PR. Can you explain? | |||||
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_node->chain, location, flags); | chainParams, *g_rpc_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,617 Lines • ▼ Show 20 Lines | |||||
void RegisterWalletRPCCommands( | void RegisterWalletRPCCommands( | ||||
interfaces::Chain &chain, | interfaces::Chain &chain, | ||||
std::vector<std::unique_ptr<interfaces::Handler>> &handlers) { | std::vector<std::unique_ptr<interfaces::Handler>> &handlers) { | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | ||||
handlers.emplace_back(chain.handleRpc(commands[vcidx])); | handlers.emplace_back(chain.handleRpc(commands[vcidx])); | ||||
} | } | ||||
} | } | ||||
interfaces::Chain *g_rpc_chain = nullptr; |
This isn't in the original PR. Can you explain?