MCPcopy Create free account
hub / github.com/ElementsProject/elements / EvalDescriptorStringOrObject

Function EvalDescriptorStringOrObject

src/rpc/util.cpp:1028–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026}
1027
1028std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider)
1029{
1030 std::string desc_str;
1031 std::pair<int64_t, int64_t> range = {0, 1000};
1032 if (scanobject.isStr()) {
1033 desc_str = scanobject.get_str();
1034 } else if (scanobject.isObject()) {
1035 UniValue desc_uni = find_value(scanobject, "desc");
1036 if (desc_uni.isNull()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Descriptor needs to be provided in scan object");
1037 desc_str = desc_uni.get_str();
1038 UniValue range_uni = find_value(scanobject, "range");
1039 if (!range_uni.isNull()) {
1040 range = ParseDescriptorRange(range_uni);
1041 }
1042 } else {
1043 throw JSONRPCError(RPC_INVALID_PARAMETER, "Scan object needs to be either a string or an object");
1044 }
1045
1046 std::string error;
1047 auto desc = Parse(desc_str, provider, error);
1048 if (!desc) {
1049 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
1050 }
1051 if (!desc->IsRange()) {
1052 range.first = 0;
1053 range.second = 0;
1054 }
1055 std::vector<CScript> ret;
1056 for (int i = range.first; i <= range.second; ++i) {
1057 std::vector<CScript> scripts;
1058 if (!desc->Expand(i, provider, scripts, provider)) {
1059 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys: '%s'", desc_str));
1060 }
1061 std::move(scripts.begin(), scripts.end(), std::back_inserter(ret));
1062 }
1063 return ret;
1064}
1065
1066UniValue GetServicesNames(ServiceFlags services)
1067{

Callers 3

FUZZ_TARGET_INITFunction · 0.85
utxoupdatepsbtFunction · 0.85
scantxoutsetFunction · 0.85

Calls 10

JSONRPCErrorFunction · 0.85
ParseDescriptorRangeFunction · 0.85
ParseFunction · 0.85
isStrMethod · 0.80
isObjectMethod · 0.80
ExpandMethod · 0.80
isNullMethod · 0.45
IsRangeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.68