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:
parent
6410705211
commit
700b7ceb73
@ -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");
|
||||||
|
|
||||||
@ -724,9 +724,6 @@ UniValue dumphdinfo(const JSONRPCRequest& request)
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NullUniValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
UniValue dumpwallet(const JSONRPCRequest& request)
|
UniValue dumpwallet(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(request.fHelp))
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
Loading…
Reference in New Issue
Block a user