@@ -2159,7 +2159,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2159
2159
{" " , RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, " An object with output descriptor and metadata" ,
2160
2160
{
2161
2161
{" 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]) " },
2163
2163
},
2164
2164
},
2165
2165
},
@@ -2216,7 +2216,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2216
2216
// loop through the scan objects
2217
2217
for (const UniValue& scanobject : request.params [1 ].get_array ().getValues ()) {
2218
2218
std::string desc_str;
2219
- int range = 1000 ;
2219
+ std::pair< int64_t , int64_t > range = { 0 , 1000 } ;
2220
2220
if (scanobject.isStr ()) {
2221
2221
desc_str = scanobject.get_str ();
2222
2222
} else if (scanobject.isObject ()) {
@@ -2225,8 +2225,8 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2225
2225
desc_str = desc_uni.get_str ();
2226
2226
UniValue range_uni = find_value (scanobject, " range" );
2227
2227
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" );
2230
2230
}
2231
2231
} else {
2232
2232
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)
2237
2237
if (!desc) {
2238
2238
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Invalid descriptor '%s'" , desc_str));
2239
2239
}
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) {
2242
2245
std::vector<CScript> scripts;
2243
2246
if (!desc->Expand (i, provider, scripts, provider)) {
2244
2247
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Cannot derive script without private keys: '%s'" , desc_str));
0 commit comments