Fix ending height bug and check that ending height is larger than starting height

This commit is contained in:
Duke Leto
2022-06-09 06:41:09 -04:00
parent e0d22ee170
commit 2b336dccc0

View File

@@ -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");
}