|
|
@ -2241,43 +2241,14 @@ UniValue scantxoutset(const JSONRPCRequest& request)
|
|
|
|
|
|
|
|
|
|
|
|
// loop through the scan objects
|
|
|
|
// loop through the scan objects
|
|
|
|
for (const UniValue& scanobject : request.params[1].get_array().getValues()) {
|
|
|
|
for (const UniValue& scanobject : request.params[1].get_array().getValues()) {
|
|
|
|
std::string desc_str;
|
|
|
|
|
|
|
|
std::pair<int64_t, int64_t> range = {0, 1000};
|
|
|
|
|
|
|
|
if (scanobject.isStr()) {
|
|
|
|
|
|
|
|
desc_str = scanobject.get_str();
|
|
|
|
|
|
|
|
} else if (scanobject.isObject()) {
|
|
|
|
|
|
|
|
UniValue desc_uni = find_value(scanobject, "desc");
|
|
|
|
|
|
|
|
if (desc_uni.isNull()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Descriptor needs to be provided in scan object");
|
|
|
|
|
|
|
|
desc_str = desc_uni.get_str();
|
|
|
|
|
|
|
|
UniValue range_uni = find_value(scanobject, "range");
|
|
|
|
|
|
|
|
if (!range_uni.isNull()) {
|
|
|
|
|
|
|
|
range = ParseDescriptorRange(range_uni);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Scan object needs to be either a string or an object");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FlatSigningProvider provider;
|
|
|
|
FlatSigningProvider provider;
|
|
|
|
auto desc = Parse(desc_str, provider);
|
|
|
|
auto scripts = EvalDescriptorStringOrObject(scanobject, provider);
|
|
|
|
if (!desc) {
|
|
|
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor '%s'", desc_str));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!desc->IsRange()) {
|
|
|
|
|
|
|
|
range.first = 0;
|
|
|
|
|
|
|
|
range.second = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = range.first; i <= range.second; ++i) {
|
|
|
|
|
|
|
|
std::vector<CScript> scripts;
|
|
|
|
|
|
|
|
if (!desc->Expand(i, provider, scripts, provider)) {
|
|
|
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys: '%s'", desc_str));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& script : scripts) {
|
|
|
|
for (const auto& script : scripts) {
|
|
|
|
std::string inferred = InferDescriptor(script, provider)->ToString();
|
|
|
|
std::string inferred = InferDescriptor(script, provider)->ToString();
|
|
|
|
needles.emplace(script);
|
|
|
|
needles.emplace(script);
|
|
|
|
descriptors.emplace(std::move(script), std::move(inferred));
|
|
|
|
descriptors.emplace(std::move(script), std::move(inferred));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Scan the unspent transaction output set for inputs
|
|
|
|
// Scan the unspent transaction output set for inputs
|
|
|
|
UniValue unspents(UniValue::VARR);
|
|
|
|
UniValue unspents(UniValue::VARR);
|
|
|
|