return "" in dumppubkey for nonexistent user

This commit is contained in:
Miguel Freitas 2013-10-29 18:02:33 -02:00
parent 6ade53ce53
commit 8d793b371d

View File

@ -230,15 +230,16 @@ Value dumppubkey(const Array& params, bool fHelp)
if (fHelp || params.size() != 1)
throw runtime_error(
"dumppubkey <username>\n"
"Returns the public key corresponding to <username>.");
"Returns the public key corresponding to <username> (empty if user doesn't exist)");
string strUsername = params[0].get_str();
CPubKey pubkey;
bool gotKey = getUserPubKey(strUsername, pubkey);
if( !gotKey )
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Username not found");
if( !gotKey ) {
return "";
}
string strPubkey = string( reinterpret_cast<const char *>(pubkey.begin()), pubkey.size());
return strPubkey;