Skip to content

Commit

Permalink
Auto merge of #4553 - oxarbitrage:issue4356, r=daira
Browse files Browse the repository at this point in the history
Return address in z_importviewingkey error

Closes zcash/zcash#4536.
  • Loading branch information
zkbot committed Nov 19, 2020
2 parents 10b09d4 + 9a5f9bf commit bf70e35
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,15 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)

auto addrInfo = boost::apply_visitor(libzcash::AddressInfoFromViewingKey{}, viewingkey);
UniValue result(UniValue::VOBJ);
const string strAddress = keyIO.EncodePaymentAddress(addrInfo.second);
result.pushKV("type", addrInfo.first);
result.pushKV("address", keyIO.EncodePaymentAddress(addrInfo.second));
result.pushKV("address", strAddress);

auto addResult = boost::apply_visitor(AddViewingKeyToWallet(pwalletMain), viewingkey);
if (addResult == SpendingKeyExists) {
throw JSONRPCError(
RPC_WALLET_ERROR,
"The wallet already contains the private key for this viewing key");
"The wallet already contains the private key for this viewing key (address: " + strAddress + ")");
} else if (addResult == KeyAlreadyExists && fIgnoreExistingKey) {
return result;
}
Expand Down

0 comments on commit bf70e35

Please sign in to comment.