From 8f49941f1335e31d34d7625246c9ad2bf05df99d Mon Sep 17 00:00:00 2001 From: tri Date: Sun, 9 Jun 2024 09:10:06 -0700 Subject: [PATCH] fix protx revoke parsing wrong input values --- src/rpc/rpcevo.cpp | 17 ++++++++--------- src/rpc/util.cpp | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/rpc/rpcevo.cpp b/src/rpc/rpcevo.cpp index b326ae479..4a39dc268 100644 --- a/src/rpc/rpcevo.cpp +++ b/src/rpc/rpcevo.cpp @@ -240,7 +240,7 @@ static CBLSPublicKey ParseBLSPubKey(const std::string &hexKey, const std::string static CBLSSecretKey ParseBLSSecretKey(const std::string &hexKey, const std::string ¶mName) { 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; } @@ -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)); } @@ -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 diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index c5b6eacef..89db6e16f 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -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;