Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show All 20 Lines | |||||
#include <wallet/rpcwallet.h> | #include <wallet/rpcwallet.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
#include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <tuple> | |||||
static std::string EncodeDumpString(const std::string &str) { | static std::string EncodeDumpString(const std::string &str) { | ||||
std::stringstream ret; | std::stringstream ret; | ||||
for (const uint8_t c : str) { | for (const uint8_t c : str) { | ||||
if (c <= 32 || c >= 128 || c == '%') { | if (c <= 32 || c >= 128 || c == '%') { | ||||
ret << '%' << HexStr(&c, &c + 1); | ret << '%' << HexStr(&c, &c + 1); | ||||
} else { | } else { | ||||
ret << c; | ret << c; | ||||
▲ Show 20 Lines • Show All 1,245 Lines • ▼ Show 20 Lines | if (!parsed_desc->IsRange() && data.exists("range")) { | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"Range should not be specified for an un-ranged descriptor"); | "Range should not be specified for an un-ranged descriptor"); | ||||
} else if (parsed_desc->IsRange()) { | } else if (parsed_desc->IsRange()) { | ||||
if (!data.exists("range")) { | if (!data.exists("range")) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"Descriptor is ranged, please specify the range"); | "Descriptor is ranged, please specify the range"); | ||||
} | } | ||||
auto range = ParseRange(data["range"]); | std::tie(range_start, range_end) = ParseDescriptorRange(data["range"]); | ||||
range_start = range.first; | |||||
range_end = range.second; | |||||
if (range_start < 0 || (range_end >> 31) != 0 || | |||||
range_end - range_start >= 1000000) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"Invalid descriptor range specified"); | |||||
} | |||||
} | } | ||||
const UniValue &priv_keys = | const UniValue &priv_keys = | ||||
data.exists("keys") ? data["keys"].get_array() : UniValue(); | data.exists("keys") ? data["keys"].get_array() : UniValue(); | ||||
// Expand all descriptors to get public keys and scripts. | // Expand all descriptors to get public keys and scripts. | ||||
// TODO: get private keys from descriptors too | // TODO: get private keys from descriptors too | ||||
for (int i = range_start; i <= range_end; ++i) { | for (int i = range_start; i <= range_end; ++i) { | ||||
▲ Show 20 Lines • Show All 487 Lines • Show Last 20 Lines |