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 51 Lines • ▼ Show 20 Lines | if (!request.params[3].isNull()) { | ||||
"Cannot encrypt a wallet with a blank password"); | "Cannot encrypt a wallet with a blank password"); | ||||
} | } | ||||
} | } | ||||
std::string error; | std::string error; | ||||
std::string warning; | std::string warning; | ||||
WalletCreationStatus status; | WalletCreationStatus status; | ||||
std::shared_ptr<CWallet> wallet = CreateWallet( | std::shared_ptr<CWallet> wallet = CreateWallet( | ||||
config.GetChainParams(), *g_rpc_node->chain, | config.GetChainParams(), *g_rpc_chain, request.params[0].get_str(), | ||||
request.params[0].get_str(), error, warning, status, passphrase, flags); | error, warning, status, passphrase, flags); | ||||
if (status == WalletCreationStatus::CREATION_FAILED) { | if (status == WalletCreationStatus::CREATION_FAILED) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, error); | throw JSONRPCError(RPC_WALLET_ERROR, error); | ||||
} else if (status == WalletCreationStatus::ENCRYPTION_FAILED) { | } else if (status == WalletCreationStatus::ENCRYPTION_FAILED) { | ||||
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error); | throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error); | ||||
} else if (status != WalletCreationStatus::SUCCESS) { | } else if (status != WalletCreationStatus::SUCCESS) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet creation failed"); | throw JSONRPCError(RPC_WALLET_ERROR, "Wallet creation failed"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,618 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; |