@@ -2159,7 +2159,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
21592159 {" " , RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, " An object with output descriptor and metadata" ,
21602160 {
21612161 {" desc" , RPCArg::Type::STR, RPCArg::Optional::NO, " An output descriptor" },
2162- {" range" , RPCArg::Type::NUM , /* default */ " 1000" , " Up to what child index HD chains should be explored " },
2162+ {" range" , RPCArg::Type::RANGE , /* default */ " 1000" , " The range of HD chain indexes to explore (either end or [begin,end]) " },
21632163 },
21642164 },
21652165 },
@@ -2216,7 +2216,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
22162216 // loop through the scan objects
22172217 for (const UniValue& scanobject : request.params [1 ].get_array ().getValues ()) {
22182218 std::string desc_str;
2219- int range = 1000 ;
2219+ std::pair< int64_t , int64_t > range = { 0 , 1000 } ;
22202220 if (scanobject.isStr ()) {
22212221 desc_str = scanobject.get_str ();
22222222 } else if (scanobject.isObject ()) {
@@ -2225,8 +2225,8 @@ UniValue scantxoutset(const JSONRPCRequest& request)
22252225 desc_str = desc_uni.get_str ();
22262226 UniValue range_uni = find_value (scanobject, " range" );
22272227 if (!range_uni.isNull ()) {
2228- range = range_uni. get_int ( );
2229- if (range < 0 || range > 1000000 ) throw JSONRPCError (RPC_INVALID_PARAMETER, " range out of range" );
2228+ range = ParseRange (range_uni );
2229+ if (range. first < 0 || ( range. second >> 31 ) != 0 || range. second >= range. first + 1000000 ) throw JSONRPCError (RPC_INVALID_PARAMETER, " range out of range" );
22302230 }
22312231 } else {
22322232 throw JSONRPCError (RPC_INVALID_PARAMETER, " Scan object needs to be either a string or an object" );
@@ -2237,8 +2237,11 @@ UniValue scantxoutset(const JSONRPCRequest& request)
22372237 if (!desc) {
22382238 throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Invalid descriptor '%s'" , desc_str));
22392239 }
2240- if (!desc->IsRange ()) range = 0 ;
2241- for (int i = 0 ; i <= range; ++i) {
2240+ if (!desc->IsRange ()) {
2241+ range.first = 0 ;
2242+ range.second = 0 ;
2243+ }
2244+ for (int i = range.first ; i <= range.second ; ++i) {
22422245 std::vector<CScript> scripts;
22432246 if (!desc->Expand (i, provider, scripts, provider)) {
22442247 throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Cannot derive script without private keys: '%s'" , desc_str));
0 commit comments