Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show All 26 Lines | |||||
#ifdef HAVE_MALLOC_INFO | #ifdef HAVE_MALLOC_INFO | ||||
#include <malloc.h> | #include <malloc.h> | ||||
#endif | #endif | ||||
static UniValue validateaddress(const Config &config, | static UniValue validateaddress(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"validateaddress", | "validateaddress", | ||||
"\nReturn information about the given bitcoin address.\n", | "Return information about the given bitcoin address.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The bitcoin address to validate"}, | "The bitcoin address to validate"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"isvalid\" : true|false, (boolean) If the address is " | " \"isvalid\" : true|false, (boolean) If the address is " | ||||
"valid or not. If not, this is the only property returned.\n" | "valid or not. If not, this is the only property returned.\n" | ||||
Show All 33 Lines | static UniValue validateaddress(const Config &config, | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue createmultisig(const Config &config, | static UniValue createmultisig(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"createmultisig", | "createmultisig", | ||||
"\nCreates a multi-signature address with n signature of m keys " | "Creates a multi-signature address with n signature of m keys " | ||||
"required.\n" | "required.\n" | ||||
"It returns a json object with the address and redeemScript.\n", | "It returns a json object with the address and redeemScript.\n", | ||||
{ | { | ||||
{"nrequired", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"nrequired", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"The number of required signatures out of the n keys."}, | "The number of required signatures out of the n keys."}, | ||||
{"keys", | {"keys", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
RPCArg::Optional::NO, | RPCArg::Optional::NO, | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | static UniValue createmultisig(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
UniValue getdescriptorinfo(const Config &config, | UniValue getdescriptorinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getdescriptorinfo", | "getdescriptorinfo", | ||||
{"\nAnalyses a descriptor.\n"}, | {"Analyses a descriptor.\n"}, | ||||
{ | { | ||||
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, | {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The descriptor."}, | "The descriptor."}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{"{\n" | ||||
" \"descriptor\" : \"desc\", (string) The " | " \"descriptor\" : \"desc\", (string) The " | ||||
"descriptor in canonical form, without private keys\n" | "descriptor in canonical form, without private keys\n" | ||||
" \"checksum\" : \"chksum\", (string) The checksum " | " \"checksum\" : \"chksum\", (string) The checksum " | ||||
Show All 30 Lines | UniValue getdescriptorinfo(const Config &config, | ||||
result.pushKV("issolvable", desc->IsSolvable()); | result.pushKV("issolvable", desc->IsSolvable()); | ||||
result.pushKV("hasprivatekeys", provider.keys.size() > 0); | result.pushKV("hasprivatekeys", provider.keys.size() > 0); | ||||
return result; | 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 " | {"Derives 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" | ||||
" sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for " | " sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for " | ||||
"the given threshold and pubkeys\n" | "the given threshold and pubkeys\n" | ||||
" raw(<hex script>) Outputs whose scriptPubKey " | " raw(<hex script>) Outputs whose scriptPubKey " | ||||
"equals the specified hex scripts\n" | "equals the specified hex scripts\n" | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | UniValue deriveaddresses(const Config &config, const JSONRPCRequest &request) { | ||||
return addresses; | return addresses; | ||||
} | } | ||||
static UniValue verifymessage(const Config &config, | static UniValue verifymessage(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"verifymessage", | "verifymessage", | ||||
"\nVerify a signed message\n", | "Verify a signed message\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The bitcoin address to use for the signature."}, | "The bitcoin address to use for the signature."}, | ||||
{"signature", RPCArg::Type::STR, RPCArg::Optional::NO, | {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The signature provided by the signer in base 64 encoding (see " | "The signature provided by the signer in base 64 encoding (see " | ||||
"signmessage)."}, | "signmessage)."}, | ||||
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, | {"message", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The message that was signed."}, | "The message that was signed."}, | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static UniValue verifymessage(const Config &config, | ||||
return (pubkey.GetID() == *pkhash); | return (pubkey.GetID() == *pkhash); | ||||
} | } | ||||
static UniValue signmessagewithprivkey(const Config &config, | static UniValue signmessagewithprivkey(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"signmessagewithprivkey", | "signmessagewithprivkey", | ||||
"\nSign a message with the private key of an address\n", | "Sign a message with the private key of an address\n", | ||||
{ | { | ||||
{"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, | {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The private key to sign the message with."}, | "The private key to sign the message with."}, | ||||
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, | {"message", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The message to create a signature of."}, | "The message to create a signature of."}, | ||||
}, | }, | ||||
RPCResult{"\"signature\" (string) The signature of the " | RPCResult{"\"signature\" (string) The signature of the " | ||||
"message encoded in base 64\n"}, | "message encoded in base 64\n"}, | ||||
Show All 29 Lines | static UniValue signmessagewithprivkey(const Config &config, | ||||
return EncodeBase64(vchSig.data(), vchSig.size()); | return EncodeBase64(vchSig.data(), vchSig.size()); | ||||
} | } | ||||
static UniValue setmocktime(const Config &config, | static UniValue setmocktime(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"setmocktime", | "setmocktime", | ||||
"\nSet the local time to given timestamp (-regtest only)\n", | "Set the local time to given timestamp (-regtest only)\n", | ||||
{ | { | ||||
{"timestamp", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"timestamp", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"Unix seconds-since-epoch timestamp\n" | "Unix seconds-since-epoch timestamp\n" | ||||
" Pass 0 to go back to using the system time."}, | " Pass 0 to go back to using the system time."}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
Show All 21 Lines | static UniValue setmocktime(const Config &config, | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue mockscheduler(const Config &config, | static UniValue mockscheduler(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"mockscheduler", | "mockscheduler", | ||||
"\nBump the scheduler into the future (-regtest only)\n", | "Bump the scheduler into the future (-regtest only)\n", | ||||
{ | { | ||||
{"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"Number of seconds to forward the scheduler into the future."}, | "Number of seconds to forward the scheduler into the future."}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | static UniValue logging(const Config &config, const JSONRPCRequest &request) { | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue echo(const Config &config, const JSONRPCRequest &request) { | static UniValue echo(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp) { | if (request.fHelp) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"echo|echojson ...", | "echo|echojson ...", | ||||
"\nSimply echo back the input arguments. This command is for " | "Simply echo back the input arguments. This command is for " | ||||
"testing.\n" | "testing.\n" | ||||
"\nThe difference between echo and echojson is that echojson has " | "\nThe difference between echo and echojson is that echojson has " | ||||
"argument conversion enabled in the client-side table in " | "argument conversion enabled in the client-side table in " | ||||
"bitcoin-cli and the GUI. There is no server-side difference.", | "bitcoin-cli and the GUI. There is no server-side difference.", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
Show All 33 Lines |