rpc: fix {sign,message}verify RPC errors for invalid address/signature
This commit is contained in:
1 parent
baf9cedee8
commit
e62f0c71f1
2 files changed
+3
-3
No files matched your search
+2
-2
@@ -300,11 +300,11 @@ static RPCHelpMan verifymessage()
|
|||||||
|
|
||||||
switch (MessageVerify(strAddress, strSign, strMessage)) {
|
switch (MessageVerify(strAddress, strSign, strMessage)) {
|
||||||
case MessageVerificationResult::ERR_INVALID_ADDRESS:
|
case MessageVerificationResult::ERR_INVALID_ADDRESS:
|
||||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||||
case MessageVerificationResult::ERR_ADDRESS_NO_KEY:
|
case MessageVerificationResult::ERR_ADDRESS_NO_KEY:
|
||||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
|
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
|
||||||
case MessageVerificationResult::ERR_MALFORMED_SIGNATURE:
|
case MessageVerificationResult::ERR_MALFORMED_SIGNATURE:
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
|
throw JSONRPCError(RPC_TYPE_ERROR, "Malformed base64 encoding");
|
||||||
case MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED:
|
case MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED:
|
||||||
case MessageVerificationResult::ERR_NOT_SIGNED:
|
case MessageVerificationResult::ERR_NOT_SIGNED:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ static UniValue signmessage(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CTxDestination dest = DecodeDestination(strAddress);
|
CTxDestination dest = DecodeDestination(strAddress);
|
||||||
if (!IsValidDestination(dest)) {
|
if (!IsValidDestination(dest)) {
|
||||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||||
}
|
}
|
||||||
|
|
||||||
const PKHash *pkhash = boost::get<PKHash>(&dest);
|
const PKHash *pkhash = boost::get<PKHash>(&dest);
|
||||||
|
|||||||
Reference in new issue
Block a user