From 2b336dccc0c51edbaac802a94b5c0f7e3d2cf502 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 9 Jun 2022 06:41:09 -0400 Subject: [PATCH] Fix ending height bug and check that ending height is larger than starting height --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"); }