diff --git a/src/avalanche/delegation.cpp b/src/avalanche/delegation.cpp --- a/src/avalanche/delegation.cpp +++ b/src/avalanche/delegation.cpp @@ -76,7 +76,8 @@ bool ret = reduceLevels(hash, levels, [&](const Level &l) { if (!pauth->VerifySchnorr(hash, l.sig)) { - return state.Invalid(DelegationResult::INVALID_SIGNATURE); + return state.Invalid(DelegationResult::INVALID_SIGNATURE, + "invalid-signature"); } // This key is valid, now up to the next delegation level. diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -384,22 +384,21 @@ if (dg.getProofId() != limitedProofId.computeProofId(dg.getProofMaster())) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "The supplied delegation does not match the proof"); + throw JSONRPCError(RPC_INVALID_PARAMETER, + "The delegation does not match the proof"); } CPubKey auth; avalanche::DelegationState dgState; if (!dg.verify(dgState, auth)) { throw JSONRPCError(RPC_INVALID_PARAMETER, - "The supplied delegation is not valid"); + "The delegation is invalid: " + + dgState.ToString()); } if (privkey.GetPubKey() != auth) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "The supplied private key does not match the delegation"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, + "The private key does not match the delegation"); } dgb = std::make_unique(dg); diff --git a/test/functional/abc_rpc_avalancheproof.py b/test/functional/abc_rpc_avalancheproof.py --- a/test/functional/abc_rpc_avalancheproof.py +++ b/test/functional/abc_rpc_avalancheproof.py @@ -201,7 +201,7 @@ # Invalid delegation bad_dg = AvalancheDelegation() - assert_raises_rpc_error(-8, "The supplied delegation does not match the proof", + assert_raises_rpc_error(-8, "The delegation does not match the proof", node.delegateavalancheproof, limited_id_hex, bytes_to_wif(privkey.get_bytes()), @@ -213,7 +213,7 @@ bad_dg.limited_proofid = proofobj.limited_proofid bad_dg.proof_master = proofobj.master bad_dg.levels = [AvalancheDelegationLevel()] - assert_raises_rpc_error(-8, "The supplied delegation is not valid", + assert_raises_rpc_error(-8, "The delegation is invalid", node.delegateavalancheproof, limited_id_hex, bytes_to_wif(privkey.get_bytes()), @@ -222,7 +222,7 @@ ) # Wrong privkey, match the proof but does not match the delegation - assert_raises_rpc_error(-8, "The supplied private key does not match the delegation", + assert_raises_rpc_error(-5, "The private key does not match the delegation", node.delegateavalancheproof, limited_id_hex, bytes_to_wif(privkey.get_bytes()),