Skip to content

Commit 1675b7c

Browse files
committed
Use stop/[start,stop] notation in importmulti desc range
1 parent 4566011 commit 1675b7c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/wallet/rpcdump.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,13 +1132,10 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
11321132
if (!data.exists("range")) {
11331133
throw JSONRPCError(RPC_INVALID_PARAMETER, "Descriptor is ranged, please specify the range");
11341134
}
1135-
const UniValue& range = data["range"];
1136-
range_start = range.exists("start") ? range["start"].get_int64() : 0;
1137-
if (!range.exists("end")) {
1138-
throw JSONRPCError(RPC_INVALID_PARAMETER, "End of range for descriptor must be specified");
1139-
}
1140-
range_end = range["end"].get_int64();
1141-
if (range_end < range_start || range_start < 0) {
1135+
auto range = ParseRange(data["range"]);
1136+
range_start = range.first;
1137+
range_end = range.second;
1138+
if (range_start < 0 || (range_end >> 31) != 0 || range_end - range_start >= 1000000) {
11421139
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid descriptor range specified");
11431140
}
11441141
}
@@ -1373,12 +1370,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
13731370
{"key", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
13741371
}
13751372
},
1376-
{"range", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "If a ranged descriptor is used, this specifies the start and end of the range to import",
1377-
{
1378-
{"start", RPCArg::Type::NUM, /* default */ "0", "Start of the range to import"},
1379-
{"end", RPCArg::Type::NUM, RPCArg::Optional::NO, "End of the range to import (inclusive)"},
1380-
}
1381-
},
1373+
{"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED, "If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import"},
13821374
{"internal", RPCArg::Type::BOOL, /* default */ "false", "Stating whether matching outputs should be treated as not incoming payments (also known as change)"},
13831375
{"watchonly", RPCArg::Type::BOOL, /* default */ "false", "Stating whether matching outputs should be considered watchonly."},
13841376
{"label", RPCArg::Type::STR, /* default */ "''", "Label to assign to the address, only allowed with internal=false"},

test/functional/wallet_importmulti.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def run_test(self):
584584
self.log.info("Should import the ranged descriptor with specified range as solvable")
585585
self.test_importmulti({"desc": descsum_create(desc),
586586
"timestamp": "now",
587-
"range": {"end": 1}},
587+
"range": 1},
588588
success=True,
589589
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
590590
for address in addresses:
@@ -807,7 +807,7 @@ def run_test(self):
807807
'desc': descsum_create('wpkh([80002067/0h/0h]' + xpub + '/*)'),
808808
'keypool': True,
809809
'timestamp': 'now',
810-
'range' : {'start': 0, 'end': 4}
810+
'range' : [0, 4],
811811
}]
812812
)
813813
for i in range(0, 5):

0 commit comments

Comments
 (0)