Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
static void verifyProofOrThrow(const NodeContext &node, avalanche::Proof &proof, | static void verifyProofOrThrow(const NodeContext &node, avalanche::Proof &proof, | ||||
const std::string &proofHex) { | const std::string &proofHex) { | ||||
bilingual_str error; | bilingual_str error; | ||||
if (!avalanche::Proof::FromHex(proof, proofHex, error)) { | if (!avalanche::Proof::FromHex(proof, proofHex, error)) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, error.original); | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, error.original); | ||||
} | } | ||||
avalanche::ProofParams proofParams; | |||||
if (g_avalanche) { | |||||
// If Avalanche is enabled, use the configured params | |||||
proofParams = g_avalanche->getProofParams(); | |||||
} | |||||
avalanche::ProofValidationState state; | avalanche::ProofValidationState state; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (!proof.verify(state, *Assert(node.chainman))) { | if (!proof.verify(proofParams, state, *Assert(node.chainman))) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"The proof is invalid: " + state.ToString()); | "The proof is invalid: " + state.ToString()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static RPCHelpMan addavalanchenode() { | static RPCHelpMan addavalanchenode() { | ||||
return RPCHelpMan{ | return RPCHelpMan{ | ||||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |