Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 378 Lines • ▼ Show 20 Lines | if (request.params.size() >= 4 && !request.params[3].isNull()) { | ||||
bilingual_str error; | bilingual_str error; | ||||
if (!avalanche::Delegation::FromHex(dg, request.params[3].get_str(), | if (!avalanche::Delegation::FromHex(dg, request.params[3].get_str(), | ||||
error)) { | error)) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, error.original); | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, error.original); | ||||
} | } | ||||
if (dg.getProofId() != | if (dg.getProofId() != | ||||
limitedProofId.computeProofId(dg.getProofMaster())) { | limitedProofId.computeProofId(dg.getProofMaster())) { | ||||
throw JSONRPCError( | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
RPC_INVALID_PARAMETER, | "The delegation does not match the proof"); | ||||
"The supplied delegation does not match the proof"); | |||||
} | } | ||||
CPubKey auth; | CPubKey auth; | ||||
avalanche::DelegationState dgState; | avalanche::DelegationState dgState; | ||||
if (!dg.verify(dgState, auth)) { | if (!dg.verify(dgState, auth)) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"The supplied delegation is not valid"); | "The delegation is invalid: " + | ||||
dgState.ToString()); | |||||
} | } | ||||
if (privkey.GetPubKey() != auth) { | if (privkey.GetPubKey() != auth) { | ||||
throw JSONRPCError( | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
RPC_INVALID_PARAMETER, | "The private key does not match the delegation"); | ||||
"The supplied private key does not match the delegation"); | |||||
} | } | ||||
dgb = std::make_unique<avalanche::DelegationBuilder>(dg); | dgb = std::make_unique<avalanche::DelegationBuilder>(dg); | ||||
} else { | } else { | ||||
dgb = std::make_unique<avalanche::DelegationBuilder>( | dgb = std::make_unique<avalanche::DelegationBuilder>( | ||||
limitedProofId, privkey.GetPubKey()); | limitedProofId, privkey.GetPubKey()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines |