Skip to content

Commit e62f0c7

Browse files
committed
rpc: fix {sign,message}verify RPC errors for invalid address/signature
1 parent baf9ced commit e62f0c7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/rpc/misc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ static RPCHelpMan verifymessage()
300300

301301
switch (MessageVerify(strAddress, strSign, strMessage)) {
302302
case MessageVerificationResult::ERR_INVALID_ADDRESS:
303-
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
303+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
304304
case MessageVerificationResult::ERR_ADDRESS_NO_KEY:
305305
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
306306
case MessageVerificationResult::ERR_MALFORMED_SIGNATURE:
307-
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
307+
throw JSONRPCError(RPC_TYPE_ERROR, "Malformed base64 encoding");
308308
case MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED:
309309
case MessageVerificationResult::ERR_NOT_SIGNED:
310310
return false;

src/wallet/rpcwallet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static UniValue signmessage(const JSONRPCRequest& request)
602602

603603
CTxDestination dest = DecodeDestination(strAddress);
604604
if (!IsValidDestination(dest)) {
605-
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
605+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
606606
}
607607

608608
const PKHash *pkhash = boost::get<PKHash>(&dest);

0 commit comments

Comments
 (0)