Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,181 Lines • ▼ Show 20 Lines | static UniValue createwallet(const Config &config, | ||||
} | } | ||||
std::string error; | std::string error; | ||||
std::string warning; | std::string warning; | ||||
std::shared_ptr<CWallet> wallet; | std::shared_ptr<CWallet> wallet; | ||||
WalletCreationStatus status = | WalletCreationStatus status = | ||||
CreateWallet(config.GetChainParams(), *g_rpc_chain, passphrase, flags, | CreateWallet(config.GetChainParams(), *g_rpc_chain, passphrase, flags, | ||||
request.params[0].get_str(), error, warning, wallet); | request.params[0].get_str(), error, warning, wallet); | ||||
if (status == WalletCreationStatus::CREATION_FAILED) { | switch (status) { | ||||
case WalletCreationStatus::CREATION_FAILED: | |||||
throw JSONRPCError(RPC_WALLET_ERROR, error); | throw JSONRPCError(RPC_WALLET_ERROR, error); | ||||
} else if (status == WalletCreationStatus::ENCRYPTION_FAILED) { | case WalletCreationStatus::ENCRYPTION_FAILED: | ||||
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error); | throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error); | ||||
} else if (status != WalletCreationStatus::SUCCESS) { | case WalletCreationStatus::SUCCESS: | ||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet creation failed"); | break; | ||||
// no default case, so the compiler can warn about missing cases | |||||
} | } | ||||
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); | ||||
return obj; | return obj; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,525 Lines • Show Last 20 Lines |