Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | static UniValue createmultisig(const Config &config, | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("address", EncodeDestination(dest, config)); | result.pushKV("address", EncodeDestination(dest, config)); | ||||
result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); | result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); | ||||
return result; | return result; | ||||
} | } | ||||
UniValue getdescriptorinfo(const Config &config, | |||||
const JSONRPCRequest &request) { | |||||
RPCHelpMan{ | |||||
"getdescriptorinfo", | |||||
{"\nAnalyses a descriptor.\n"}, | |||||
{ | |||||
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, | |||||
"The descriptor."}, | |||||
}, | |||||
RPCResult{"{\n" | |||||
" \"descriptor\" : \"desc\", (string) The " | |||||
"descriptor in canonical form, without private keys\n" | |||||
" \"isrange\" : true|false, (boolean) Whether the " | |||||
"descriptor is ranged\n" | |||||
" \"issolvable\" : true|false, (boolean) Whether the " | |||||
"descriptor is solvable\n" | |||||
" \"hasprivatekeys\" : true|false, (boolean) Whether the " | |||||
"input descriptor contained at least one private key\n" | |||||
"}\n"}, | |||||
RPCExamples{"Analyse a descriptor\n" + | |||||
HelpExampleCli("getdescriptorinfo", | |||||
"\"pkh([d34db33f/84h/0h/" | |||||
"0h]" | |||||
"0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2" | |||||
"dce28d959f2815b16f81798)\"")}} | |||||
.Check(request); | |||||
RPCTypeCheck(request.params, {UniValue::VSTR}); | |||||
FlatSigningProvider provider; | |||||
auto desc = Parse(request.params[0].get_str(), provider); | |||||
if (!desc) { | |||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | |||||
strprintf("Invalid descriptor")); | |||||
} | |||||
UniValue result(UniValue::VOBJ); | |||||
result.pushKV("descriptor", desc->ToString()); | |||||
result.pushKV("isrange", desc->IsRange()); | |||||
result.pushKV("issolvable", desc->IsSolvable()); | |||||
result.pushKV("hasprivatekeys", provider.keys.size() > 0); | |||||
return result; | |||||
} | |||||
UniValue deriveaddresses(const Config &config, const JSONRPCRequest &request) { | UniValue deriveaddresses(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"deriveaddresses", | "deriveaddresses", | ||||
{"\nDerives one or more addresses corresponding to an output " | {"\nDerives one or more addresses corresponding to an output " | ||||
"descriptor.\n" | "descriptor.\n" | ||||
"Examples of output descriptors are:\n" | "Examples of output descriptors are:\n" | ||||
" pkh(<pubkey>) P2PKH outputs for the given " | " pkh(<pubkey>) P2PKH outputs for the given " | ||||
"pubkey\n" | "pubkey\n" | ||||
▲ Show 20 Lines • Show All 516 Lines • ▼ Show 20 Lines | |||||
static const CRPCCommand commands[] = { | static const CRPCCommand commands[] = { | ||||
// category name actor (function) argNames | // category name actor (function) argNames | ||||
// ------------------- ------------------------ ---------------------- ---------- | // ------------------- ------------------------ ---------------------- ---------- | ||||
{ "control", "getmemoryinfo", getmemoryinfo, {"mode"} }, | { "control", "getmemoryinfo", getmemoryinfo, {"mode"} }, | ||||
{ "control", "logging", logging, {"include", "exclude"} }, | { "control", "logging", logging, {"include", "exclude"} }, | ||||
{ "util", "validateaddress", validateaddress, {"address"} }, | { "util", "validateaddress", validateaddress, {"address"} }, | ||||
{ "util", "createmultisig", createmultisig, {"nrequired","keys"} }, | { "util", "createmultisig", createmultisig, {"nrequired","keys"} }, | ||||
{ "util", "deriveaddresses", deriveaddresses, {"descriptor", "begin", "end"} }, | { "util", "deriveaddresses", deriveaddresses, {"descriptor", "begin", "end"} }, | ||||
{ "util", "getdescriptorinfo", getdescriptorinfo, {"descriptor"} }, | |||||
{ "util", "verifymessage", verifymessage, {"address","signature","message"} }, | { "util", "verifymessage", verifymessage, {"address","signature","message"} }, | ||||
{ "util", "signmessagewithprivkey", signmessagewithprivkey, {"privkey","message"} }, | { "util", "signmessagewithprivkey", signmessagewithprivkey, {"privkey","message"} }, | ||||
/* Not shown in help */ | /* Not shown in help */ | ||||
{ "hidden", "setmocktime", setmocktime, {"timestamp"}}, | { "hidden", "setmocktime", setmocktime, {"timestamp"}}, | ||||
{ "hidden", "mockscheduler", mockscheduler, {"delta_time"}}, | { "hidden", "mockscheduler", mockscheduler, {"delta_time"}}, | ||||
{ "hidden", "echo", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, | { "hidden", "echo", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, | ||||
{ "hidden", "echojson", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, | { "hidden", "echojson", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
void RegisterMiscRPCCommands(CRPCTable &t) { | void RegisterMiscRPCCommands(CRPCTable &t) { | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | ||||
t.appendCommand(commands[vcidx].name, &commands[vcidx]); | t.appendCommand(commands[vcidx].name, &commands[vcidx]); | ||||
} | } | ||||
} | } |