File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -523,3 +523,17 @@ std::string RPCArg::ToString(const bool oneline) const
523523 }
524524 assert (false );
525525}
526+
527+ std::pair<int64_t , int64_t > ParseRange (const UniValue& value)
528+ {
529+ if (value.isNum ()) {
530+ return {0 , value.get_int64 ()};
531+ }
532+ if (value.isArray () && value.size () == 2 && value[0 ].isNum () && value[1 ].isNum ()) {
533+ int64_t low = value[0 ].get_int64 ();
534+ int64_t high = value[1 ].get_int64 ();
535+ if (low > high) throw JSONRPCError (RPC_INVALID_PARAMETER, " Range specified as [begin,end] must not have begin after end" );
536+ return {low, high};
537+ }
538+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Range must be specified as end or as [begin,end]" );
539+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ unsigned int ParseConfirmTarget(const UniValue& value);
3838RPCErrorCode RPCErrorFromTransactionError (TransactionError terr);
3939UniValue JSONRPCTransactionError (TransactionError terr, const std::string& err_string = " " );
4040
41+ // ! Parse a JSON range specified as int64, or [int64, int64]
42+ std::pair<int64_t , int64_t > ParseRange (const UniValue& value);
43+
4144struct RPCArg {
4245 enum class Type {
4346 OBJ,
You can’t perform that action at this time.
0 commit comments