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

Function getdescriptorinfo

src/rpc/misc.cpp:219–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219static RPCHelpMan getdescriptorinfo()
220{
221 const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)";
222
223 return RPCHelpMan{"getdescriptorinfo",
224 {"\nAnalyses a descriptor.\n"},
225 {
226 {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
227 },
228 RPCResult{
229 RPCResult::Type::OBJ, "", "",
230 {
231 {RPCResult::Type::STR, "descriptor", "The descriptor in canonical form, without private keys"},
232 {RPCResult::Type::STR, "checksum", "The checksum for the input descriptor"},
233 {RPCResult::Type::BOOL, "isrange", "Whether the descriptor is ranged"},
234 {RPCResult::Type::BOOL, "issolvable", "Whether the descriptor is solvable"},
235 {RPCResult::Type::BOOL, "hasprivatekeys", "Whether the input descriptor contained at least one private key"},
236 }
237 },
238 RPCExamples{
239 "Analyse a descriptor\n" +
240 HelpExampleCli("getdescriptorinfo", "\"" + EXAMPLE_DESCRIPTOR + "\"") +
241 HelpExampleRpc("getdescriptorinfo", "\"" + EXAMPLE_DESCRIPTOR + "\"")
242 },
243 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
244{
245 RPCTypeCheck(request.params, {UniValue::VSTR});
246
247 FlatSigningProvider provider;
248 std::string error;
249 auto desc = Parse(request.params[0].get_str(), provider, error);
250 if (!desc) {
251 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
252 }
253
254 UniValue result(UniValue::VOBJ);
255 result.pushKV("descriptor", desc->ToString());
256 result.pushKV("checksum", GetDescriptorChecksum(request.params[0].get_str()));
257 result.pushKV("isrange", desc->IsRange());
258 result.pushKV("issolvable", desc->IsSolvable());
259 result.pushKV("hasprivatekeys", provider.keys.size() > 0);
260 return result;
261},
262 };
263}
264
265static RPCHelpMan deriveaddresses()
266{

Callers

nothing calls this directly

Calls 11

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
RPCTypeCheckFunction · 0.85
ParseFunction · 0.85
JSONRPCErrorFunction · 0.85
GetDescriptorChecksumFunction · 0.85
pushKVMethod · 0.45
ToStringMethod · 0.45
IsRangeMethod · 0.45
IsSolvableMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected