mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 14959753a4 into merged_master (Bitcoin PR #15744)
This commit is contained in:
commit
3fd900ce76
7 changed files with 48 additions and 23 deletions
|
|
@ -11,6 +11,8 @@
|
|||
#include <assetsdir.h>
|
||||
#include <core_io.h>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
InitInterfaces* g_rpc_interfaces = nullptr;
|
||||
|
||||
void RPCTypeCheck(const UniValue& params,
|
||||
|
|
@ -665,7 +667,7 @@ std::string RPCArg::ToString(const bool oneline) const
|
|||
assert(false);
|
||||
}
|
||||
|
||||
std::pair<int64_t, int64_t> ParseRange(const UniValue& value)
|
||||
static std::pair<int64_t, int64_t> ParseRange(const UniValue& value)
|
||||
{
|
||||
if (value.isNum()) {
|
||||
return {0, value.get_int64()};
|
||||
|
|
@ -679,6 +681,22 @@ std::pair<int64_t, int64_t> ParseRange(const UniValue& value)
|
|||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Range must be specified as end or as [begin,end]");
|
||||
}
|
||||
|
||||
std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value)
|
||||
{
|
||||
int64_t low, high;
|
||||
std::tie(low, high) = ParseRange(value);
|
||||
if (low < 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Range should be greater or equal than 0");
|
||||
}
|
||||
if ((high >> 31) != 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "End of range is too high");
|
||||
}
|
||||
if (high >= low + 1000000) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Range is too large");
|
||||
}
|
||||
return {low, high};
|
||||
}
|
||||
|
||||
//
|
||||
// ELEMENTS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue