Introduce wrappers around CZCViewingKey

This commit is contained in:
Jack Grigg
2018-04-24 22:53:54 +01:00
parent 472f75bc2d
commit 8bf3a3d700
4 changed files with 25 additions and 7 deletions

View File

@@ -705,8 +705,11 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
}
string strVKey = params[0].get_str();
CZCViewingKey viewingkey(strVKey);
auto vkey = viewingkey.Get();
auto viewingkey = DecodeViewingKey(strVKey);
if (!viewingkey) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid viewing key");
}
auto vkey = *viewingkey;
auto addr = vkey.address();
{
@@ -815,6 +818,5 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
vk = k.viewing_key();
}
CZCViewingKey viewingkey(vk);
return viewingkey.ToString();
return EncodeViewingKey(vk);
}

View File

@@ -3067,12 +3067,10 @@ UniValue zc_raw_keygen(const UniValue& params, bool fHelp)
auto addr = k.address();
auto viewing_key = k.viewing_key();
CZCViewingKey viewingkey(viewing_key);
UniValue result(UniValue::VOBJ);
result.push_back(Pair("zcaddress", EncodePaymentAddress(addr)));
result.push_back(Pair("zcsecretkey", EncodeSpendingKey(k)));
result.push_back(Pair("zcviewingkey", viewingkey.ToString()));
result.push_back(Pair("zcviewingkey", EncodeViewingKey(viewing_key)));
return result;
}