diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -215,11 +215,10 @@ } peerData = std::make_unique(); - { - // The proof. - CDataStream stream(ParseHex(argsman.GetArg("-avaproof", "")), - SER_NETWORK, 0); - stream >> peerData->proof; + if (!Proof::FromHex(peerData->proof, argsman.GetArg("-avaproof", ""), + error)) { + // error is set by FromHex + return nullptr; } ProofValidationState proof_state; diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -80,10 +80,11 @@ const NodeId nodeid = request.params[0].get_int64(); const CPubKey key = ParsePubKey(request.params[1]); - CDataStream ss(ParseHexV(request.params[2], "proof"), SER_NETWORK, - PROTOCOL_VERSION); avalanche::Proof proof; - ss >> proof; + bilingual_str error; + if (!avalanche::Proof::FromHex(proof, request.params[2].get_str(), error)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, error.original); + } if (key != proof.getMaster()) { // TODO: we want to provide a proper delegation. @@ -242,11 +243,11 @@ } avalanche::Proof proof; - { - CDataStream ss(ParseHexV(request.params[0], "proof"), SER_NETWORK, - PROTOCOL_VERSION); - ss >> proof; + bilingual_str error; + if (!avalanche::Proof::FromHex(proof, request.params[0].get_str(), error)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, error.original); } + avalanche::ProofValidationState proofState; if (!proof.verify(proofState)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "The proof is invalid");