Skip to content

Commit

Permalink
fix protx revoke parsing wrong input values (Raptor3um#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
npq7721 authored Jun 10, 2024
1 parent b292eb6 commit 6a30dd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/rpc/rpcevo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static CBLSPublicKey ParseBLSPubKey(const std::string &hexKey, const std::string
static CBLSSecretKey ParseBLSSecretKey(const std::string &hexKey, const std::string &paramName) {
CBLSSecretKey secKey;
if (!secKey.SetHexStr(hexKey)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be a valid BLS secret key", paramName));
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be a valid BLS secret key %s", paramName, hexKey));
}
return secKey;
}
Expand Down Expand Up @@ -1023,12 +1023,11 @@ UniValue protx_revoke(const JSONRPCRequest& request)

CProUpRevTx ptx;
ptx.nVersion = CProUpRevTx::CURRENT_VERSION;
ptx.proTxHash = ParseHashV(request.params[1], "proTxHash");

CBLSSecretKey keyOperator = ParseBLSSecretKey(request.params[2].get_str(), "operatorKey");
ptx.proTxHash = ParseHashV(request.params[0], "proTxHash");

if (!request.params[3].isNull()) {
int32_t nReason = ParseInt32V(request.params[3], "reason");
CBLSSecretKey keyOperator = ParseBLSSecretKey(request.params[1].get_str(), "operatorKey");
if (!request.params[2].isNull()) {
int32_t nReason = ParseInt32V(request.params[2], "reason");
if (nReason < 0 || nReason > CProUpRevTx::REASON_LAST) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("invalid reason %d, must be between 0 and %d", nReason, CProUpRevTx::REASON_LAST));
}
Expand All @@ -1048,10 +1047,10 @@ UniValue protx_revoke(const JSONRPCRequest& request)
tx.nVersion = 3;
tx.nType = TRANSACTION_PROVIDER_UPDATE_REVOKE;

if (!request.params[4].isNull()) {
CTxDestination feeSourceDest = DecodeDestination(request.params[4].get_str());
if (!request.params[3].isNull()) {
CTxDestination feeSourceDest = DecodeDestination(request.params[3].get_str());
if (!IsValidDestination(feeSourceDest))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Raptoreum address: ") + request.params[4].get_str());
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Raptoreum address: ") + request.params[3].get_str());
FundSpecialTx(pwallet, tx, ptx, feeSourceDest);
} else if (dmn->pdmnState->scriptOperatorPayout != CScript()) {
// Using funds from previousely specified operator payout address
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ uint256 ParseHashV(const UniValue &v, std::string strName) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strName + " must be hexadecimal string (not '" + strHex + "')");
if (64 != strHex.length())
throw JSONRPCError(RPC_INVALID_PARAMETER,
strprintf("%s must be of length %d (not %d)", strName, 64, strHex.length()));
strprintf("%s must be of length %d (not %d): %s", strName, 64, strHex.length(), strHex));
uint256 result;
result.SetHex(strHex);
return result;
Expand Down

0 comments on commit 6a30dd8

Please sign in to comment.