Use switch on status in RpcWallet

This commit is contained in:
Fabian Jahr 2019-07-12 14:06:55 -04:00 committed by Fabian Jahr
parent ba1f128d6c
commit e967cae8fa

View file

@ -2686,12 +2686,14 @@ static UniValue createwallet(const JSONRPCRequest& request)
std::string warning; std::string warning;
std::shared_ptr<CWallet> wallet; std::shared_ptr<CWallet> wallet;
WalletCreationStatus status = CreateWallet(*g_rpc_interfaces->chain, passphrase, flags, request.params[0].get_str(), error, warning, wallet); WalletCreationStatus status = CreateWallet(*g_rpc_interfaces->chain, passphrase, flags, 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);