diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3a5498f19..8e6d8b128 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3716,11 +3716,15 @@ UniValue z_anonsetblockdelta(const UniValue& params, bool fHelp, const CPubKey& std::string strHeight2 = params[1].get_str(); int nHeight2 = -1; try { - nHeight = std::stoi(strHeight2); + nHeight2 = std::stoi(strHeight2); } catch (const std::exception &e) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid ending block height parameter"); } + if (nHeight2 <= nHeight) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height must be larger than starting height"); + } + if (nHeight2 < 0 || nHeight2 > chainActive.Height()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height out of range"); }