RPC: dumphdinfo should throw an error when wallet isn't HD (#2134)

* Throws an RPCError `RPC_WALLET_ERROR` when the command `dumphdinfo` is called and the wallet is not HD

* Refactor based on @Udjin's post
This commit is contained in:
PaulieD 2018-06-19 00:52:32 -05:00 committed by UdjinM6
parent 6410705211
commit 700b7ceb73

View File

@ -705,10 +705,10 @@ UniValue dumphdinfo(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
// add the base58check encoded extended master if the wallet uses HD
CHDChain hdChainCurrent; CHDChain hdChainCurrent;
if (pwalletMain->GetHDChain(hdChainCurrent)) if (!pwalletMain->GetHDChain(hdChainCurrent))
{ throw JSONRPCError(RPC_WALLET_ERROR, "This wallet is not a HD wallet.");
if (!pwalletMain->GetDecryptedHDChain(hdChainCurrent)) if (!pwalletMain->GetDecryptedHDChain(hdChainCurrent))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Cannot decrypt HD seed"); throw JSONRPCError(RPC_INTERNAL_ERROR, "Cannot decrypt HD seed");
@ -722,9 +722,6 @@ UniValue dumphdinfo(const JSONRPCRequest& request)
obj.push_back(Pair("mnemonicpassphrase", ssMnemonicPassphrase.c_str())); obj.push_back(Pair("mnemonicpassphrase", ssMnemonicPassphrase.c_str()));
return obj; return obj;
}
return NullUniValue;
} }
UniValue dumpwallet(const JSONRPCRequest& request) UniValue dumpwallet(const JSONRPCRequest& request)