Auto merge of #4553 - oxarbitrage:issue4356, r=daira
Return address in z_importviewingkey error Closes https://github.com/zcash/zcash/issues/4536.
This commit is contained in:
commit
bf70e357cf
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue