From 85537e453276735f87994f39e36e3259142b5ddc Mon Sep 17 00:00:00 2001 From: Dzutte Date: Fri, 5 Nov 2021 11:47:35 -0700 Subject: [PATCH] Dash-specific changes to support RPCHelpMan improvements Signed-off-by: Dzutte --- src/rpc/blockchain.cpp | 141 +++++++++++---------- src/rpc/coinjoin.cpp | 41 +++--- src/rpc/governance.cpp | 198 +++++++++++++++++------------ src/rpc/masternode.cpp | 132 ++++++++++++-------- src/rpc/misc.cpp | 198 ++++++++++++++++------------- src/rpc/rpcevo.cpp | 264 +++++++++++++++++++++------------------ src/rpc/rpcquorums.cpp | 216 ++++++++++++++++++-------------- src/wallet/rpcdump.cpp | 28 +++-- src/wallet/rpcwallet.cpp | 59 +++++---- 9 files changed, 709 insertions(+), 568 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 3c22716070..6518efaa32 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -231,19 +231,20 @@ static UniValue getbestchainlock(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"getbestchainlock", "\nReturns information about the best chainlock. Throws an error if there is no known chainlock yet.", - {} - }.ToString() + - "\nResult:\n" - "{\n" - " \"blockhash\" : \"hash\", (string) The block hash hex-encoded\n" - " \"height\" : n, (numeric) The block height or index\n" - " \"signature\" : \"hash\", (string) The chainlock's BLS signature.\n" - " \"known_block\" : true|false (boolean) True if the block is known by our node\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getbestchainlock", "") - + HelpExampleRpc("getbestchainlock", "") - ); + {}, + RPCResult{ + "{\n" + " \"blockhash\" : \"hash\", (string) The block hash hex-encoded\n" + " \"height\" : n, (numeric) The block height or index\n" + " \"signature\" : \"hash\", (string) The chainlock's BLS signature.\n" + " \"known_block\" : true|false (boolean) True if the block is known by our node\n" + "}\n" + }, + RPCExamples{ + HelpExampleCli("getbestchainlock", "") + + HelpExampleRpc("getbestchainlock", "") + }, + }.ToString()); UniValue result(UniValue::VOBJ); llmq::CChainLockSig clsig = llmq::chainLocksHandler->GetBestChainLock(); @@ -761,18 +762,19 @@ static UniValue getblockhashes(const JSONRPCRequest& request) RPCHelpMan{"getblockhashes", "\nReturns array of hashes of blocks within the timestamp range provided.\n", { - {"high", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The newer block timestamp"}, - {"low", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The older block timestamp"}, - }} - .ToString() + - "\nResult:\n" - "[\n" - " \"hash\" (string) The block hash\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getblockhashes", "1231614698 1231024505") - + HelpExampleRpc("getblockhashes", "1231614698, 1231024505") - ); + {"high", RPCArg::Type::NUM, RPCArg::Optional::NO, "The newer block timestamp"}, + {"low", RPCArg::Type::NUM, RPCArg::Optional::NO, "The older block timestamp"}, + }, + RPCResult{ + "[\n" + " \"hash\" (string) The block hash\n" + "]\n" + }, + RPCExamples{ + HelpExampleCli("getblockhashes", "1231614698 1231024505") + + HelpExampleRpc("getblockhashes", "1231614698, 1231024505") + }, + }.ToString()); unsigned int high = request.params[0].get_int(); unsigned int low = request.params[1].get_int(); @@ -898,12 +900,12 @@ static UniValue getblockheaders(const JSONRPCRequest& request) "\nIf verbose is false, each item is a string that is serialized, hex-encoded data for a single blockheader.\n" "If verbose is true, each item is an Object with information about a single blockheader.\n", { - {"hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"}, - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, - {"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "true for a json object, false for the hex-encoded data"}, - }} - .ToString() + - "\nResult (for verbose = true):\n" + {"hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, + {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, + {"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"}, + }, + RPCResults{ + {"for verbose = true", "[ {\n" " \"hash\" : \"hash\", (string) The block hash\n" " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" @@ -923,15 +925,17 @@ static UniValue getblockheaders(const JSONRPCRequest& request) " },\n" "...\n" "]\n" - "\nResult (for verbose=false):\n" + },{"for verbose=false", "[\n" " \"data\", (string) A string that is serialized, hex-encoded data for block header.\n" " ...\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getblockheaders", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 2000") + }}, + RPCExamples{ + HelpExampleCli("getblockheaders", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 2000") + HelpExampleRpc("getblockheaders", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 2000") - ); + }, + }.ToString()); LOCK(cs_main); @@ -1007,20 +1011,21 @@ static UniValue getmerkleblocks(const JSONRPCRequest& request) RPCHelpMan{"getmerkleblocks", "\nReturns an array of hex-encoded merkleblocks for blocks starting from which match .\n", { - {"filter", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex-encoded bloom filter"}, - {"hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"}, - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, - }} - .ToString() + - "\nResult:\n" + {"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"}, + {"hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, + {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, + }, + RPCResult{ "[\n" " \"data\", (string) A string that is serialized, hex-encoded data for a merkleblock.\n" " ...\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getmerkleblocks", "\"2303028005802040100040000008008400048141010000f8400420800080025004000004130000000000000001\" \"00000000007e1432d2af52e8463278bf556b55cf5049262f25634557e2e91202\" 2000") + }, + RPCExamples{ + HelpExampleCli("getmerkleblocks", "\"2303028005802040100040000008008400048141010000f8400420800080025004000004130000000000000001\" \"00000000007e1432d2af52e8463278bf556b55cf5049262f25634557e2e91202\" 2000") + HelpExampleRpc("getmerkleblocks", "\"2303028005802040100040000008008400048141010000f8400420800080025004000004130000000000000001\" \"00000000007e1432d2af52e8463278bf556b55cf5049262f25634557e2e91202\" 2000") - ); + }, + }.ToString()); LOCK(cs_main); @@ -1588,8 +1593,8 @@ static UniValue getchaintips(const JSONRPCRequest& request) "Return information about all known tips in the block tree," " including the main chain as well as orphaned branches.\n", { - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "only show this much of latest tips"}, - {"branchlen", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "only show tips that have equal or greater length of branch"}, + {"count", RPCArg::Type::NUM, /* default */ "", "only show this much of latest tips"}, + {"branchlen", RPCArg::Type::NUM, /* default */ "", "only show tips that have equal or greater length of branch"}, }, RPCResult{ "[\n" @@ -2269,29 +2274,31 @@ static UniValue getspecialtxes(const JSONRPCRequest& request) "If verbosity is 1, returns hex-encoded data for each transaction.\n" "If verbosity is 2, returns an Object with information for each transaction.\n", { - {"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"}, - {"type", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "-1", "Filter special txes by type, -1 means all types"}, - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "10", "The number of transactions to return"}, - {"skip", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "The number of transactions to skip"}, - {"verbosity", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "0 for hashes, 1 for hex-encoded data, and 2 for json object"}, - }} - .ToString() + - "\nResult (for verbosity = 0):\n" + {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, + {"type", RPCArg::Type::NUM, /* default */ "-1", "Filter special txes by type, -1 means all types"}, + {"count", RPCArg::Type::NUM, /* default */ "10", "The number of transactions to return"}, + {"skip", RPCArg::Type::NUM, /* default */ "0", "The number of transactions to skip"}, + {"verbosity", RPCArg::Type::NUM, /* default */ "0", "0 for hashes, 1 for hex-encoded data, and 2 for json object"}, + }, + RPCResults{ + {"for verbosity = 0", "[\n" " \"txid\" : \"xxxx\", (string) The transaction id\n" "]\n" - "\nResult (for verbosity = 1):\n" + }, {"for verbosity = 1", "[\n" " \"data\", (string) A string that is serialized, hex-encoded data for the transaction\n" "]\n" - "\nResult (for verbosity = 2):\n" + }, {"for verbosity = 2", "[ (array of Objects) The transactions in the format of the getrawtransaction RPC.\n" " ...,\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getspecialtxes", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"") + }}, + RPCExamples{ + HelpExampleCli("getspecialtxes", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"") + HelpExampleRpc("getspecialtxes", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"") - ); + }, + }.ToString()); LOCK(cs_main); @@ -2620,17 +2627,19 @@ static UniValue getblockfilter(const JSONRPCRequest& request) RPCHelpMan{"getblockfilter", "\nRetrieve a BIP 157 content filter for a particular block.\n", { - {"blockhash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The hash of the block"}, - {"filtertype", RPCArg::Type::STR, /* opt */ true, /* default_val */ "basic", "The type name of the filter"}, - }} - .ToString() + - "\nResult:\n" + {"blockhash", RPCArg::Type::STR, RPCArg::Optional::NO, "The hash of the block"}, + {"filtertype", RPCArg::Type::STR, /* default */ "basic", "The type name of the filter"}, + }, + RPCResult{ "{\n" " \"filter\" : (string) the hex-encoded filter data\n" " \"header\" : (string) the hex-encoded filter header\n" "}\n" - + HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"") - ); + }, + RPCExamples{ + HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"") + }, + }.ToString()); } uint256 block_hash = ParseHashV(request.params[0], "blockhash"); diff --git a/src/rpc/coinjoin.cpp b/src/rpc/coinjoin.cpp index ebe62b192f..58c0115937 100644 --- a/src/rpc/coinjoin.cpp +++ b/src/rpc/coinjoin.cpp @@ -26,16 +26,16 @@ static UniValue coinjoin(const JSONRPCRequest& request) if (request.fHelp || request.params.size() != 1) throw std::runtime_error( RPCHelpMan{"coinjoin", - "", + "\nAvailable commands:\n" + " start - Start mixing\n" + " stop - Stop mixing\n" + " reset - Reset mixing", { - {"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"}, - }} - .ToString() + - "\nAvailable commands:\n" - " start - Start mixing\n" - " stop - Stop mixing\n" - " reset - Reset mixing\n" - ); + {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); if (fMasternodeMode) throw JSONRPCError(RPC_INTERNAL_ERROR, "Client-side mixing is not supported on masternodes"); @@ -87,9 +87,10 @@ static UniValue getpoolinfo(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"getpoolinfo", "DEPRECATED. Please use getcoinjoininfo instead.\n", - {}} - .ToString() - ); + {}, + RPCResults{}, + RPCExamples{""}} + .ToString()); } static UniValue getcoinjoininfo(const JSONRPCRequest& request) @@ -98,9 +99,9 @@ static UniValue getcoinjoininfo(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"getcoinjoininfo", "Returns an object containing an information about CoinJoin settings and state.\n", - {}} - .ToString() + - "\nResult (for regular nodes):\n" + {}, + RPCResults{ + {"for regular nodes", "{\n" " \"enabled\": true|false, (bool) Whether mixing functionality is enabled\n" " \"multisession\": true|false, (bool) Whether CoinJoin Multisession option is enabled\n" @@ -126,17 +127,19 @@ static UniValue getcoinjoininfo(const JSONRPCRequest& request) " \"keys_left\": xxx, (numeric) How many new keys are left since last automatic backup\n" " \"warnings\": \"...\" (string) Warnings if any\n" "}\n" - "\nResult (for masternodes):\n" + }, {"for masternodes", "{\n" " \"queue_size\": xxx, (numeric) How many queues there are currently on the network\n" " \"denomination\": xxx, (numeric) The denomination of the mixing session in " + CURRENCY_UNIT + "\n" " \"state\": \"...\", (string) Current state of the mixing session\n" " \"entries_count\": xxx, (numeric) The number of entries in the mixing session\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("getcoinjoininfo", "") + }}, + RPCExamples{ + HelpExampleCli("getcoinjoininfo", "") + HelpExampleRpc("getcoinjoininfo", "") - ); + }, + }.ToString()); } UniValue obj(UniValue::VOBJ); diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index 67d2e1662e..1f9012acfc 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -31,9 +31,11 @@ static void gobject_count_help() RPCHelpMan{"gobject count", "Count governance objects and votes\n", { - {"mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "json", "Output format: json (\"json\") or string in free form (\"all\")"}, - }} - .ToString()); + {"mode", RPCArg::Type::STR, /* default */ "json", "Output format: json (\"json\") or string in free form (\"all\")"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_count(const JSONRPCRequest& request) @@ -59,9 +61,11 @@ static void gobject_deserialize_help() RPCHelpMan {"gobject deserialize", "Deserialize governance object from hex string to JSON\n", { - {"hex_data", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string form"}, - }} - .ToString()); + {"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_deserialize(const JSONRPCRequest& request) @@ -86,9 +90,11 @@ static void gobject_check_help() RPCHelpMan{"gobject check", "Validate governance object data (proposal only)\n", { - {"hex_data", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string format"}, - }} - .ToString()); + {"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string format"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_check(const JSONRPCRequest& request) @@ -131,15 +137,17 @@ static void gobject_prepare_help(CWallet* const pwallet) "Prepare governance object by signing and creating tx\n" + HelpRequiringPassphrase(pwallet) + "\n", { - {"parent-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the parent object, \"0\" is root"}, - {"revision", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "object revision in the system"}, - {"time", RPCArg::Type::NUM, /* opt */ false, /* default_val */"", "time this object was created"}, - {"data-hex", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string form"}, - {"use-IS", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Deprecated and ignored"}, - {"outputHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "the single output to submit the proposal fee from"}, - {"outputIndex", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The output index."}, - }} - .ToString()); + {"parent-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the parent object, \"0\" is root"}, + {"revision", RPCArg::Type::NUM, RPCArg::Optional::NO, "object revision in the system"}, + {"time", RPCArg::Type::NUM, RPCArg::Optional::NO, "time this object was created"}, + {"data-hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"}, + {"use-IS", RPCArg::Type::BOOL, /* default */ "false", "Deprecated and ignored"}, + {"outputHash", RPCArg::Type::STR_HEX, /* default */ "", "the single output to submit the proposal fee from"}, + {"outputIndex", RPCArg::Type::NUM, /* default */ "", "The output index."}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_prepare(const JSONRPCRequest& request) @@ -256,9 +264,11 @@ static void gobject_list_prepared_help(CWallet* const pwallet) "Returns a list of governance objects prepared by this wallet with \"gobject prepare\" sorted by their creation time.\n" + HelpRequiringPassphrase(pwallet) + "\n", { - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "10", "Maximum number of objects to return."}, - }} - .ToString()); + {"count", RPCArg::Type::NUM, /* default */ "10", "Maximum number of objects to return."}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_list_prepared(const JSONRPCRequest& request) @@ -305,13 +315,15 @@ static void gobject_submit_help() RPCHelpMan{"gobject submit", "Submit governance object to network\n", { - {"parent-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the parent object, \"0\" is root"}, - {"revision", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "object revision in the system"}, - {"time", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "time this object was created"}, - {"data-hex", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string form"}, - {"fee-txid", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "fee-tx id, required for all objects except triggers"}, - }} - .ToString()); + {"parent-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the parent object, \"0\" is root"}, + {"revision", RPCArg::Type::NUM, RPCArg::Optional::NO, "object revision in the system"}, + {"time", RPCArg::Type::NUM, RPCArg::Optional::NO, "time this object was created"}, + {"data-hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"}, + {"fee-txid", RPCArg::Type::STR_HEX, /* default */ "", "fee-tx id, required for all objects except triggers"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_submit(const JSONRPCRequest& request) @@ -418,11 +430,13 @@ static void gobject_vote_conf_help() RPCHelpMan{"gobject vote-conf", "Vote on a governance object by masternode configured in dash.conf\n", { - {"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the governance object"}, - {"vote", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote, possible values: [funding|valid|delete|endorsed]"}, - {"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote outcome, possible values: [yes|no|abstain]"}, - }} - .ToString()); + {"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the governance object"}, + {"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"}, + {"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_vote_conf(const JSONRPCRequest& request) @@ -591,11 +605,13 @@ static void gobject_vote_many_help(CWallet* const pwallet) "Vote on a governance object by all masternodes for which the voting key is present in the local wallet\n" + HelpRequiringPassphrase(pwallet) + "\n", { - {"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the governance object"}, - {"vote", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote, possible values: [funding|valid|delete|endorsed]"}, - {"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote outcome, possible values: [yes|no|abstain]"}, - }} - .ToString()); + {"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the governance object"}, + {"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"}, + {"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_vote_many(const JSONRPCRequest& request) @@ -646,12 +662,14 @@ static void gobject_vote_alias_help(CWallet* const pwallet) "Vote on a governance object by masternode's voting key (if present in local wallet)\n" + HelpRequiringPassphrase(pwallet) + "\n", { - {"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the governance object"}, - {"vote", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote, possible values: [funding|valid|delete|endorsed]"}, - {"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote outcome, possible values: [yes|no|abstain]"}, - {"protx-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "masternode's proTxHash"}, - }} - .ToString()); + {"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the governance object"}, + {"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"}, + {"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"}, + {"protx-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "masternode's proTxHash"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_vote_alias(const JSONRPCRequest& request) @@ -764,10 +782,12 @@ static void gobject_list_help() RPCHelpMan{"gobject list", "List governance objects (can be filtered by signal and/or object type)\n", { - {"signal", RPCArg::Type::STR, /* opt */ true, /* default_val */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"}, - {"type", RPCArg::Type::STR, /* opt */ true, /* default_val */ "all", "object type, possible values: [proposals|triggers|all]"}, - }} - .ToString()); + {"signal", RPCArg::Type::STR, /* default */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"}, + {"type", RPCArg::Type::STR, /* default */ "all", "object type, possible values: [proposals|triggers|all]"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_list(const JSONRPCRequest& request) @@ -798,10 +818,12 @@ static void gobject_diff_help() RPCHelpMan{"gobject diff", "List differences since last diff or list\n", { - {"signal", RPCArg::Type::STR, /* opt */ true, /* default_val */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"}, - {"type", RPCArg::Type::STR, /* opt */ true, /* default_val */ "all", "object type, possible values: [proposals|triggers|all]"}, - }} - .ToString()); + {"signal", RPCArg::Type::STR, /* default */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"}, + {"type", RPCArg::Type::STR, /* default */ "all", "object type, possible values: [proposals|triggers|all]"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_diff(const JSONRPCRequest& request) @@ -832,9 +854,11 @@ static void gobject_get_help() RPCHelpMan{"gobject get", "Get governance object by hash\n", { - {"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "object id"}, - }} - .ToString()); + {"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "object id"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_get(const JSONRPCRequest& request) @@ -922,11 +946,13 @@ static void gobject_getcurrentvotes_help() RPCHelpMan{"gobject getcurrentvotes", "Get only current (tallying) votes for a governance object hash (does not include old votes)\n", { - {"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "object id"}, - {"txid", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "masternode collateral txid"}, - {"vout", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "masternode collateral output index, required if presents"}, - }} - .ToString()); + {"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "object id"}, + {"txid", RPCArg::Type::STR_HEX, /* default */ "", "masternode collateral txid"}, + {"vout", RPCArg::Type::STR, /* default */ "", "masternode collateral output index, required if presents"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue gobject_getcurrentvotes(const JSONRPCRequest& request) @@ -995,7 +1021,9 @@ static UniValue gobject_getcurrentvotes(const JSONRPCRequest& request) " vote-many - Vote on a governance object by all masternodes for which the voting key is in the wallet\n" #endif // ENABLE_WALLET , - {} + {}, + RPCResults{}, + RPCExamples{""} }.ToString()); } @@ -1063,15 +1091,17 @@ static UniValue voteraw(const JSONRPCRequest& request) RPCHelpMan{"voteraw", "Compile and relay a governance vote with provided external signature instead of signing vote internally\n", { - {"mn-collateral-tx-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""}, - {"mn-collateral-tx-index", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", ""}, - {"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""}, - {"vote-signal", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", ""}, - {"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "yes|no|abstain"}, - {"time", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", ""}, - {"vote-sig", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""}, - }} - .ToString()); + {"mn-collateral-tx-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""}, + {"mn-collateral-tx-index", RPCArg::Type::NUM, RPCArg::Optional::NO, ""}, + {"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""}, + {"vote-signal", RPCArg::Type::STR, RPCArg::Optional::NO, ""}, + {"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "yes|no|abstain"}, + {"time", RPCArg::Type::NUM, RPCArg::Optional::NO, ""}, + {"vote-sig", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); uint256 hashMnCollateralTx = ParseHashV(request.params[0], "mn collateral tx hash"); int nMnCollateralTxIndex = request.params[1].get_int(); @@ -1142,9 +1172,8 @@ static UniValue getgovernanceinfo(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"getgovernanceinfo", "Returns an object containing governance parameters.\n", - {}} - .ToString() + - "\nResult:\n" + {}, + RPCResult{ "{\n" " \"governanceminquorum\": xxxxx, (numeric) the absolute minimum number of votes needed to trigger a governance action\n" " \"proposalfee\": xxx.xx, (numeric) the collateral transaction fee which must be paid to create a proposal in " + CURRENCY_UNIT + "\n" @@ -1152,10 +1181,12 @@ static UniValue getgovernanceinfo(const JSONRPCRequest& request) " \"lastsuperblock\": xxxxx, (numeric) the block number of the last superblock\n" " \"nextsuperblock\": xxxxx, (numeric) the block number of the next superblock\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("getgovernanceinfo", "") + }, + RPCExamples{ + HelpExampleCli("getgovernanceinfo", "") + HelpExampleRpc("getgovernanceinfo", "") - ); + }, + }.ToString()); } int nLastSuperblock = 0, nNextSuperblock = 0; @@ -1180,15 +1211,16 @@ static UniValue getsuperblockbudget(const JSONRPCRequest& request) RPCHelpMan{"getsuperblockbudget", "\nReturns the absolute maximum sum of superblock payments allowed.\n", { - {"index", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The block index"}, - }} - .ToString() + - "\nResult:\n" + {"index", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block index"}, + }, + RPCResult{ "n (numeric) The absolute maximum sum of superblock payments allowed, in " + CURRENCY_UNIT + "\n" - "\nExamples:\n" - + HelpExampleCli("getsuperblockbudget", "1000") + }, + RPCExamples{ + HelpExampleCli("getsuperblockbudget", "1000") + HelpExampleRpc("getsuperblockbudget", "1000") - ); + }, + }.ToString()); } int nBlockHeight = request.params[0].get_int(); diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index e1dddafb5a..9d7f9f765c 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -29,29 +29,30 @@ static void masternode_list_help() { throw std::runtime_error( RPCHelpMan{"masternodelist", - "Get a list of masternodes in different modes. This call is identical to 'masternode list' call.\n", + "Get a list of masternodes in different modes. This call is identical to 'masternode list' call.\n" + "Available modes:\n" + " addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n" + " full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n" + " (can be additionally filtered, partial match)\n" + " info - Print info in format 'status payee IP'\n" + " (can be additionally filtered, partial match)\n" + " json - Print info in JSON format (can be additionally filtered, partial match)\n" + " lastpaidblock - Print the last block height a node was paid on the network\n" + " lastpaidtime - Print the last time a node was paid on the network\n" + " owneraddress - Print the masternode owner Dash address\n" + " payee - Print the masternode payout Dash address (can be additionally filtered,\n" + " partial match)\n" + " pubKeyOperator - Print the masternode operator public key\n" + " status - Print masternode status: ENABLED / POSE_BANNED\n" + " (can be additionally filtered, partial match)\n" + " votingaddress - Print the masternode voting Dash address\n", { - {"mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "json", "The mode to run list in"}, - {"filter", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available"}, - }} - .ToString() + - "\nAvailable modes:\n" - " addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n" - " full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n" - " (can be additionally filtered, partial match)\n" - " info - Print info in format 'status payee IP'\n" - " (can be additionally filtered, partial match)\n" - " json - Print info in JSON format (can be additionally filtered, partial match)\n" - " lastpaidblock - Print the last block height a node was paid on the network\n" - " lastpaidtime - Print the last time a node was paid on the network\n" - " owneraddress - Print the masternode owner Dash address\n" - " payee - Print the masternode payout Dash address (can be additionally filtered,\n" - " partial match)\n" - " pubKeyOperator - Print the masternode operator public key\n" - " status - Print masternode status: ENABLED / POSE_BANNED\n" - " (can be additionally filtered, partial match)\n" - " votingaddress - Print the masternode voting Dash address\n" - ); + {"mode", RPCArg::Type::STR, /* default */ "json", "The mode to run list in"}, + {"filter", RPCArg::Type::STR, /* default */ "", "Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available"}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue masternode_list(const JSONRPCRequest& request) @@ -73,9 +74,11 @@ static void masternode_connect_help() RPCHelpMan{"masternode connect", "Connect to given masternode\n", { - {"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The address of the masternode to connect"}, - }} - .ToString()); + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the masternode to connect"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_connect(const JSONRPCRequest& request) @@ -102,7 +105,10 @@ static void masternode_count_help() throw std::runtime_error( RPCHelpMan{"masternode count", "Get information about number of masternodes.\n", - {}}.ToString()); + {}, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_count(const JSONRPCRequest& request) @@ -151,7 +157,10 @@ static void masternode_winner_help() throw std::runtime_error( RPCHelpMan{"masternode winner", "Print info on next masternode winner to vote for\n", - {}}.ToString()); + {}, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_winner(const JSONRPCRequest& request) @@ -171,7 +180,10 @@ static void masternode_current_help() throw std::runtime_error( RPCHelpMan{"masternode current", "Print info on current masternode winner to be paid the next block (calculated locally)\n", - {}}.ToString()); + {}, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_current(const JSONRPCRequest& request) @@ -188,7 +200,10 @@ static void masternode_outputs_help() throw std::runtime_error( RPCHelpMan{"masternode outputs", "Print masternode compatible outputs\n", - {}}.ToString()); + {}, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_outputs(const JSONRPCRequest& request) @@ -226,7 +241,10 @@ static void masternode_status_help() throw std::runtime_error( RPCHelpMan{"masternode status", "Print masternode status information\n", - {}}.ToString()); + {}, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_status(const JSONRPCRequest& request) @@ -304,9 +322,12 @@ static void masternode_winners_help() RPCHelpMan{"masternode winners", "Print list of masternode winners\n", { - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "number of last winners to return"}, - {"filter", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "filter for returned winners"}, - }}.ToString()); + {"count", RPCArg::Type::NUM, /* default */ "", "number of last winners to return"}, + {"filter", RPCArg::Type::STR, /* default */ "", "filter for returned winners"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); } static UniValue masternode_winners(const JSONRPCRequest& request) @@ -360,11 +381,10 @@ static void masternode_payments_help() RPCHelpMan{"masternode payments", "\nReturns an array of deterministic masternodes and their payments for the specified block\n", { - {"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "tip", "The hash of the starting block"}, - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "1", "The number of blocks to return. Will return previous blocks if is negative. Both 1 and -1 correspond to the chain tip."}, - }} - .ToString() + - "\nResult:\n" + {"blockhash", RPCArg::Type::STR_HEX, /* default */ "tip", "The hash of the starting block"}, + {"count", RPCArg::Type::NUM, /* default */ "1", "The number of blocks to return. Will return previous blocks if is negative. Both 1 and -1 correspond to the chain tip."}, + }, + RPCResult { " [ (array) Blocks\n" " {\n" " \"height\" : n, (numeric) The height of the block\n" @@ -384,7 +404,10 @@ static void masternode_payments_help() " },...\n" " ]\n" " },...\n" - " ]\n"); + " ]" + }, + RPCExamples{""} + }.ToString()); } static UniValue masternode_payments(const JSONRPCRequest& request) @@ -501,23 +524,24 @@ static UniValue masternode_payments(const JSONRPCRequest& request) { throw std::runtime_error( RPCHelpMan{"masternode", - "Set of commands to execute masternode related actions\n", - { - {"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"}, - }} - .ToString() + - "\nAvailable commands:\n" - " count - Get information about number of masternodes\n" - " current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n" + "Set of commands to execute masternode related actions\n" + "\nAvailable commands:\n" + " count - Get information about number of masternodes\n" + " current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n" #ifdef ENABLE_WALLET - " outputs - Print masternode compatible outputs\n" + " outputs - Print masternode compatible outputs\n" #endif // ENABLE_WALLET - " status - Print masternode status information\n" - " list - Print list of all known masternodes (see masternodelist for more info)\n" - " payments - Return information about masternode payments in a mined block\n" - " winner - DEPRECATED Print info on next masternode winner to vote for\n" - " winners - Print list of masternode winners\n" - ); + " status - Print masternode status information\n" + " list - Print list of all known masternodes (see masternodelist for more info)\n" + " payments - Return information about masternode payments in a mined block\n" + " winner - DEPRECATED Print info on next masternode winner to vote for\n" + " winners - Print list of masternode winners\n", + { + {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue masternode(const JSONRPCRequest& request) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 668488485d..aec84a41bd 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -52,15 +52,15 @@ static UniValue debug(const JSONRPCRequest& request) " - \"none\" (or \"0\") deactivates all categories at once.\n" "Note: If specified category doesn't match any of the above, no error is thrown.\n", { - {"category", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The name of the debug category to turn on."}, - }} - .ToString() + - "\nResult:\n" + {"category", RPCArg::Type::STR, RPCArg::Optional::NO, "The name of the debug category to turn on."}, + }, + RPCResult { " result (string) \"Debug mode: \" followed by the specified category.\n" - "\nExamples:\n" - + HelpExampleCli("debug", "dash") + }, + RPCExamples { + HelpExampleCli("debug", "dash") + HelpExampleRpc("debug", "dash+net") - ); + }}.ToString()); std::string strMode = request.params[0].get_str(); LogInstance().DisableCategory(BCLog::ALL); @@ -84,10 +84,11 @@ static UniValue mnsync(const JSONRPCRequest& request) RPCHelpMan{"mnsync", "Returns the sync status, updates to the next step or resets it entirely.\n", { - {"mode", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "[status|next|reset]"}, - }} - .ToString() - ); + {"mode", RPCArg::Type::STR, RPCArg::Optional::NO, "[status|next|reset]"}, + }, + RPCResults{}, + RPCExamples{""} + }.ToString()); std::string strMode = request.params[0].get_str(); @@ -145,23 +146,24 @@ static UniValue spork(const JSONRPCRequest& request) RPCHelpMan{"spork", "\nShows information about current state of sporks\n", { - {"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "'show' to show all current spork values, 'active' to show which sporks are active"}, - }} - .ToString() + - "\nResult:\n" - "For 'show':\n" + {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'show' to show all current spork values, 'active' to show which sporks are active"}, + }, + RPCResults { + {"For 'show'", "{\n" " \"SPORK_NAME\" : spork_value, (number) The value of the specific spork with the name SPORK_NAME\n" " ...\n" "}\n" - "For 'active':\n" + }, {"For 'active'", "{\n" " \"SPORK_NAME\" : true|false, (boolean) 'true' for time-based sporks if spork is active and 'false' otherwise\n" " ...\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("spork", "show") - + HelpExampleRpc("spork", "\"show\"")); + }}, + RPCExamples { + HelpExampleCli("spork", "show") + + HelpExampleRpc("spork", "\"show\"") + }}.ToString()); } else { // advanced mode, update spork values SporkId nSporkID = CSporkManager::GetSporkIDByName(request.params[0].get_str()); @@ -182,15 +184,17 @@ static UniValue spork(const JSONRPCRequest& request) RPCHelpMan{"spork", "\nUpdate the value of the specific spork. Requires \"-sporkkey\" to be set to sign the message.\n", { - {"name", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The name of the spork to update"}, - {"value", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The new desired value of the spork"}, - }} - .ToString() + - "\nResult:\n" + {"name", RPCArg::Type::STR, RPCArg::Optional::NO, "The name of the spork to update"}, + {"value", RPCArg::Type::NUM, RPCArg::Optional::NO, "The new desired value of the spork"}, + }, + RPCResult{ " result (string) \"success\" if spork value was updated or this help otherwise\n" - "\nExamples:\n" - + HelpExampleCli("spork", "SPORK_2_INSTANTSEND_ENABLED 4070908800") - + HelpExampleRpc("spork", "\"SPORK_2_INSTANTSEND_ENABLED\", 4070908800")); + }, + RPCExamples{ + HelpExampleCli("spork", "SPORK_2_INSTANTSEND_ENABLED 4070908800") + + HelpExampleRpc("spork", "\"SPORK_2_INSTANTSEND_ENABLED\", 4070908800") + }, + }.ToString()); } } @@ -300,9 +304,9 @@ UniValue getdescriptorinfo(const JSONRPCRequest& request) RPCHelpMan{"getdescriptorinfo", {"\nAnalyses a descriptor.\n"}, { - {"descriptor", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The descriptor"}, - }}.ToString() + - "\nResult:\n" + {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor"}, + }, + RPCResult{ "{\n" " \"descriptor\" : \"desc\", (string) The descriptor in canonical form, without private keys\n" " \"checksum\" : \"chksum\", (string) The checksum for the input descriptor\n" @@ -310,10 +314,12 @@ UniValue getdescriptorinfo(const JSONRPCRequest& request) " \"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" - "\nExamples:\n" + }, + RPCExamples{ "\nAnalyse a descriptor\n" + HelpExampleCli("getdescriptorinfo", "\"pkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)\"") - ); + } + }.ToString()); } RPCTypeCheck(request.params, {UniValue::VSTR}); @@ -347,19 +353,21 @@ UniValue deriveaddresses(const JSONRPCRequest& request) "or more path elements separated by \"/\", where \"h\" represents a hardened child key.\n" "For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n", { - {"descriptor", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The descriptor"}, - {"begin", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "If a ranged descriptor is used, this specifies the beginning of the range to import"}, - {"end", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "If a ranged descriptor is used, this specifies the end of the range to import"}} - }.ToString() + - "\nResult:\n" + {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor"}, + {"begin", RPCArg::Type::NUM, /* default */ "", "If a ranged descriptor is used, this specifies the beginning of the range to import"}, + {"end", RPCArg::Type::NUM, /* default */ "", "If a ranged descriptor is used, this specifies the end of the range to import"} + }, + RPCResult{ "\"address\" (array) A json array of the derived addresses\n" " [\n" " ...\n" " ]\n" - "\nExamples:\n" + }, + RPCExamples{ "\nFirst three receive addresses\n" + HelpExampleCli("deriveaddresses", "\"pkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#trd0mf0l\" 0 2") - ); + } + }.ToString()); } RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VNUM, UniValue::VNUM}); @@ -561,11 +569,13 @@ static UniValue mnauth(const JSONRPCRequest& request) RPCHelpMan{"mnauth", "\nOverride MNAUTH processing results for the specified node with a user provided data (-regtest only).\n", { - {"nodeId", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Internal peer id of the node the mock data gets added to."}, - {"proTxHash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The authenticated proTxHash as hex string."}, - {"publicKey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The authenticated public key as hex string."}, - }} - .ToString()); + {"nodeId", RPCArg::Type::NUM, RPCArg::Optional::NO, "Internal peer id of the node the mock data gets added to."}, + {"proTxHash", RPCArg::Type::STR, RPCArg::Optional::NO, "The authenticated proTxHash as hex string."}, + {"publicKey", RPCArg::Type::STR, RPCArg::Optional::NO, "The authenticated public key as hex string."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); if (!Params().MineBlocksOnDemand()) throw std::runtime_error("mnauth for regression testing (-regtest mode) only"); @@ -667,13 +677,13 @@ static UniValue getaddressmempool(const JSONRPCRequest& request) RPCHelpMan{"getaddressmempool", "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "", + {"addresses", RPCArg::Type::ARR, /* default */ "", "", { - {"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, }, }, - }}.ToString() + - "\nResult:\n" + }, + RPCResult{ "[\n" " {\n" " \"address\" (string) The base58check encoded address\n" @@ -685,10 +695,12 @@ static UniValue getaddressmempool(const JSONRPCRequest& request) " \"prevout\" (string) The previous transaction output index (if spending)\n" " }\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + }, + RPCExamples{ + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}") - ); + }, + }.ToString()); std::vector > addresses; @@ -737,13 +749,13 @@ static UniValue getaddressutxos(const JSONRPCRequest& request) RPCHelpMan{"getaddressutxos", "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "", + {"addresses", RPCArg::Type::ARR, /* default */ "", "", { - {"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, }, }, - }}.ToString() + - "\nResult:\n" + }, + RPCResult{ "[\n" " {\n" " \"address\" (string) The address base58check encoded\n" @@ -754,10 +766,12 @@ static UniValue getaddressutxos(const JSONRPCRequest& request) " \"height\" (number) The block height\n" " }\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + }, + RPCExamples{ + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}") - ); + }, + }.ToString()); std::vector > addresses; @@ -803,13 +817,13 @@ static UniValue getaddressdeltas(const JSONRPCRequest& request) RPCHelpMan{"getaddressdeltas", "\nReturns all changes for an address (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "", + {"addresses", RPCArg::Type::ARR, /* default */ "", "", { - {"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, }, }, - }}.ToString() + - "\nResult:\n" + }, + RPCResult{ "[\n" " {\n" " \"satoshis\" (number) The difference of duffs\n" @@ -820,10 +834,12 @@ static UniValue getaddressdeltas(const JSONRPCRequest& request) " \"address\" (string) The base58check encoded address\n" " }\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + }, + RPCExamples{ + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}") - ); + }, + }.ToString()); UniValue startValue = find_value(request.params[0].get_obj(), "start"); @@ -888,23 +904,25 @@ static UniValue getaddressbalance(const JSONRPCRequest& request) RPCHelpMan{"getaddressbalance", "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "", + {"addresses", RPCArg::Type::ARR, /* default */ "", "", { - {"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, }, }, - }}.ToString() + - "\nResult:\n" + }, + RPCResult{ "{\n" " \"balance\": xxxxx, (numeric) The current total balance in duffs\n" " \"balance_immature\": xxxxx, (numeric) The current immature balance in duffs\n" " \"balance_spendable\": xxxxx, (numeric) The current spendable balance in duffs\n" " \"received\": xxxxx (numeric) The total number of duffs received (including change)\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + }, + RPCExamples{ + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}") - ); + }, + }.ToString()); std::vector > addresses; @@ -956,21 +974,23 @@ static UniValue getaddresstxids(const JSONRPCRequest& request) RPCHelpMan{"getaddresstxids", "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "", + {"addresses", RPCArg::Type::ARR, /* default */ "", "", { - {"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, }, }, - }}.ToString() + - "\nResult:\n" + }, + RPCResult{ "[\n" " \"transactionid\" (string) The transaction id\n" " ,...\n" "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + }, + RPCExamples{ + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'") + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}") - ); + }, + }.ToString()); std::vector > addresses; @@ -1036,23 +1056,25 @@ static UniValue getspentinfo(const JSONRPCRequest& request) RPCHelpMan{"getspentinfo", "\nReturns the txid and index where an output is spent.\n", { - {"request", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "", + {"request", RPCArg::Type::OBJ, /* default */ "", "", { - {"txid", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The hex string of the txid"}, - {"index", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The start block height"}, + {"txid", RPCArg::Type::STR_HEX, /* default */ "", "The hex string of the txid"}, + {"index", RPCArg::Type::NUM, /* default */ "", "The start block height"}, }, }, - }}.ToString() + - "\nResult:\n" + }, + RPCResult{ "{\n" " \"txid\" (string) The transaction id\n" " \"index\" (number) The spending input index\n" " ,...\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") + }, + RPCExamples{ + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}") - ); + }, + }.ToString()); UniValue txidValue = find_value(request.params[0].get_obj(), "txid"); UniValue indexValue = find_value(request.params[0].get_obj(), "index"); diff --git a/src/rpc/rpcevo.cpp b/src/rpc/rpcevo.cpp index e6df6a3423..ce8e417d4b 100644 --- a/src/rpc/rpcevo.cpp +++ b/src/rpc/rpcevo.cpp @@ -39,96 +39,96 @@ static RPCArg GetHelpString(const std::string& strParamName) { static const std::map mapParamHelp = { {"collateralAddress", - {"collateralAddress", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"collateralAddress", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to send the collateral to."} }, {"collateralHash", - {"collateralHash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"collateralHash", RPCArg::Type::STR, RPCArg::Optional::NO, "The collateral transaction hash."} }, {"collateralIndex", - {"collateralIndex", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", + {"collateralIndex", RPCArg::Type::NUM, RPCArg::Optional::NO, "The collateral transaction output index."} }, {"feeSourceAddress", - {"feeSourceAddress", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", + {"feeSourceAddress", RPCArg::Type::STR, /* default */ "", "If specified wallet will only use coins from this address to fund ProTx.\n" "If not specified, payoutAddress is the one that is going to be used.\n" "The private key belonging to this address must be known in your wallet."} }, {"fundAddress", - {"fundAddress", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", + {"fundAddress", RPCArg::Type::STR, /* default */ "", "If specified wallet will only use coins from this address to fund ProTx.\n" "If not specified, payoutAddress is the one that is going to be used.\n" "The private key belonging to this address must be known in your wallet."} }, {"ipAndPort", - {"ipAndPort", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"ipAndPort", RPCArg::Type::STR, RPCArg::Optional::NO, "IP and port in the form \"IP:PORT\".\n" "Must be unique on the network. Can be set to 0, which will require a ProUpServTx afterwards."} }, {"operatorKey", - {"operatorKey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"operatorKey", RPCArg::Type::STR, RPCArg::Optional::NO, "The operator BLS private key associated with the\n" "registered operator public key."} }, {"operatorPayoutAddress", - {"operatorPayoutAddress", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", + {"operatorPayoutAddress", RPCArg::Type::STR, /* default */ "", "The address used for operator reward payments.\n" "Only allowed when the ProRegTx had a non-zero operatorReward value.\n" "If set to an empty string, the currently active payout address is reused."} }, {"operatorPubKey_register", - {"operatorPubKey_register", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"operatorPubKey_register", RPCArg::Type::STR, RPCArg::Optional::NO, "The operator BLS public key. The BLS private key does not have to be known.\n" "It has to match the BLS private key which is later used when operating the masternode."} }, {"operatorPubKey_update", - {"operatorPubKey_update", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"operatorPubKey_update", RPCArg::Type::STR, RPCArg::Optional::NO, "The operator BLS public key. The BLS private key does not have to be known.\n" "It has to match the BLS private key which is later used when operating the masternode.\n" "If set to an empty string, the currently active operator BLS public key is reused."} }, {"operatorReward", - {"operatorReward", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"operatorReward", RPCArg::Type::STR, RPCArg::Optional::NO, "The fraction in %% to share with the operator. The value must be\n" "between 0.00 and 100.00."} }, {"ownerAddress", - {"ownerAddress", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"ownerAddress", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to use for payee updates and proposal voting.\n" "The corresponding private key does not have to be known by your wallet.\n" "The address must be unused and must differ from the collateralAddress."} }, {"payoutAddress_register", - {"payoutAddress_register", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"payoutAddress_register", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to use for masternode reward payments."} }, {"payoutAddress_update", - {"payoutAddress_update", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"payoutAddress_update", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to use for masternode reward payments.\n" "If set to an empty string, the currently active payout address is reused."} }, {"proTxHash", - {"proTxHash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"proTxHash", RPCArg::Type::STR, RPCArg::Optional::NO, "The hash of the initial ProRegTx."} }, {"reason", - {"reason", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", + {"reason", RPCArg::Type::NUM, /* default */ "", "The reason for masternode service revocation."} }, {"submit", - {"submit", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", + {"submit", RPCArg::Type::BOOL, /* default */ "true", "If true, the resulting transaction is sent to the network."} }, {"votingAddress_register", - {"votingAddress_register", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"votingAddress_register", RPCArg::Type::STR, RPCArg::Optional::NO, "The voting key address. The private key does not have to be known by your wallet.\n" "It has to match the private key which is later used when voting on proposals.\n" "If set to an empty string, ownerAddress will be used."} }, {"votingAddress_update", - {"votingAddress_update", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", + {"votingAddress_update", RPCArg::Type::STR, RPCArg::Optional::NO, "The voting key address. The private key does not have to be known by your wallet.\n" "It has to match the private key which is later used when voting on proposals.\n" "If set to an empty string, the currently active voting key address is reused."} @@ -336,15 +336,17 @@ static void protx_register_fund_help(CWallet* const pwallet) GetHelpString("payoutAddress_register"), GetHelpString("fundAddress"), GetHelpString("submit"), - }} - .ToString() + - "\nResult (if \"submit\" is not set or set to true):\n" + }, + RPCResults{ + {"if \"submit\" is not set or set to true", "\"txid\" (string) The transaction id.\n" - "\nResult (if \"submit\" is set to false):\n" + }, {"if \"submit\" is set to false", "\"hex\" (string) The serialized signed ProTx in hex format.\n" - "\nExamples:\n" - + HelpExampleCli("protx", "register_fund \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\" \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") - ); + }}, + RPCExamples{ + HelpExampleCli("protx", "register_fund \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\" \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") + }, + }.ToString()); } static void protx_register_help(CWallet* const pwallet) @@ -366,15 +368,17 @@ static void protx_register_help(CWallet* const pwallet) GetHelpString("payoutAddress_register"), GetHelpString("feeSourceAddress"), GetHelpString("submit"), - }} - .ToString() + - "\nResult (if \"submit\" is not set or set to true):\n" + }, + RPCResults{ + {"if \"submit\" is not set or set to true", "\"txid\" (string) The transaction id.\n" - "\nResult (if \"submit\" is set to false):\n" + }, {"if \"submit\" is set to false", "\"hex\" (string) The serialized signed ProTx in hex format.\n" - "\nExamples:\n" - + HelpExampleCli("protx", "register \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") - ); + }}, + RPCExamples{ + HelpExampleCli("protx", "register \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") + }, + }.ToString()); } static void protx_register_prepare_help() @@ -394,18 +398,19 @@ static void protx_register_prepare_help() GetHelpString("operatorReward"), GetHelpString("payoutAddress_register"), GetHelpString("feeSourceAddress"), - }} - .ToString() + - "\nResult:\n" + }, + RPCResult{ "{ (json object)\n" " \"tx\" : (string) The serialized unsigned ProTx in hex format.\n" " \"collateralAddress\" : (string) The collateral address.\n" " \"signMessage\" : (string) The string message that needs to be signed with\n" " the collateral key.\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("protx", "register_prepare \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") - ); + }, + RPCExamples{ + HelpExampleCli("protx", "register_prepare \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") + }, + }.ToString()); } static void protx_register_submit_help(CWallet* const pwallet) @@ -417,15 +422,16 @@ static void protx_register_submit_help(CWallet* const pwallet) "Note: See \"help protx register_prepare\" for more info about creating a ProTx and a message to sign.\n" + HelpRequiringPassphrase(pwallet) + "\n", { - {"tx", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The serialized unsigned ProTx in hex format."}, - {"sig", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The signature signed with the collateral key. Must be in base64 format."}, - }} - .ToString() + - "\nResult:\n" + {"tx", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The serialized unsigned ProTx in hex format."}, + {"sig", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature signed with the collateral key. Must be in base64 format."}, + }, + RPCResult{ "\"txid\" (string) The transaction id.\n" - "\nExamples:\n" - + HelpExampleCli("protx", "register_submit \"tx\" \"sig\"") - ); + }, + RPCExamples{ + HelpExampleCli("protx", "register_submit \"tx\" \"sig\"") + }, + }.ToString()); } // handles register, register_prepare and register_fund in one method @@ -639,13 +645,14 @@ static void protx_update_service_help(CWallet* const pwallet) GetHelpString("operatorKey"), GetHelpString("operatorPayoutAddress"), GetHelpString("feeSourceAddress"), - }} - .ToString() + - "\nResult:\n" + }, + RPCResult{ "\"txid\" (string) The transaction id.\n" - "\nExamples:\n" - + HelpExampleCli("protx", "update_service \"0123456701234567012345670123456701234567012345670123456701234567\" \"1.2.3.4:1234\" 5a2e15982e62f1e0b7cf9783c64cf7e3af3f90a52d6c40f6f95d624c0b1621cd") - ); + }, + RPCExamples{ + HelpExampleCli("protx", "update_service \"0123456701234567012345670123456701234567012345670123456701234567\" \"1.2.3.4:1234\" 5a2e15982e62f1e0b7cf9783c64cf7e3af3f90a52d6c40f6f95d624c0b1621cd") + }, + }.ToString()); } static UniValue protx_update_service(const JSONRPCRequest& request) @@ -737,13 +744,14 @@ static void protx_update_registrar_help(CWallet* const pwallet) GetHelpString("votingAddress_update"), GetHelpString("payoutAddress_update"), GetHelpString("feeSourceAddress"), - }} - .ToString() + - "\nResult:\n" + }, + RPCResult{ "\"txid\" (string) The transaction id.\n" - "\nExamples:\n" - + HelpExampleCli("protx", "update_registrar \"0123456701234567012345670123456701234567012345670123456701234567\" \"982eb34b7c7f614f29e5c665bc3605f1beeef85e3395ca12d3be49d2868ecfea5566f11cedfad30c51b2403f2ad95b67\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"") - ); + }, + RPCExamples{ + HelpExampleCli("protx", "update_registrar \"0123456701234567012345670123456701234567012345670123456701234567\" \"982eb34b7c7f614f29e5c665bc3605f1beeef85e3395ca12d3be49d2868ecfea5566f11cedfad30c51b2403f2ad95b67\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"") + }, + }.ToString()); } static UniValue protx_update_registrar(const JSONRPCRequest& request) @@ -828,13 +836,14 @@ static void protx_revoke_help(CWallet* const pwallet) GetHelpString("operatorKey"), GetHelpString("reason"), GetHelpString("feeSourceAddress"), - }} - .ToString() + - "\nResult:\n" + }, + RPCResult{ "\"txid\" (string) The transaction id.\n" - "\nExamples:\n" - + HelpExampleCli("protx", "revoke \"0123456701234567012345670123456701234567012345670123456701234567\" \"072f36a77261cdd5d64c32d97bac417540eddca1d5612f416feb07ff75a8e240\"") - ); + }, + RPCExamples{ + HelpExampleCli("protx", "revoke \"0123456701234567012345670123456701234567012345670123456701234567\" \"072f36a77261cdd5d64c32d97bac417540eddca1d5612f416feb07ff75a8e240\"") + }, + }.ToString()); } static UniValue protx_revoke(const JSONRPCRequest& request) @@ -909,14 +918,7 @@ static void protx_list_help() RPCHelpMan{"protx list", "\nLists all ProTxs in your wallet or on-chain, depending on the given type.\n", { - {"type", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", ""}, - {"detailed", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "", ""}, - {"height", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", ""}, - }} - .ToString() + - "If \"type\" is not specified, it defaults to \"registered\".\n" - "If \"detailed\" is not specified, it defaults to \"false\" and only the hashes of the ProTx will be returned.\n" - "If \"height\" is not specified, it defaults to the current chain-tip.\n" + {"type", RPCArg::Type::STR, /* default */ "registered", "\nAvailable types:\n" " registered - List all ProTx which are registered at the given chain height.\n" " This will also include ProTx which failed PoSe verification.\n" @@ -925,7 +927,13 @@ static void protx_list_help() " wallet - List only ProTx which are found in your wallet at the given chain height.\n" " This will also include ProTx which failed PoSe verification.\n" #endif - ); + }, + {"detailed", RPCArg::Type::BOOL, /* default */ "false", "If not specified, only the hashes of the ProTx will be returned."}, + {"height", RPCArg::Type::NUM, /* default */ "current chain-tip", ""}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } #ifdef ENABLE_WALLET @@ -1086,14 +1094,15 @@ static void protx_info_help() "\nReturns detailed information about a deterministic masternode.\n", { GetHelpString("proTxHash"), - }} - .ToString() + - "\nResult:\n" + }, + RPCResult{ "{ (json object) Details about a specific deterministic masternode\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("protx", "info \"0123456701234567012345670123456701234567012345670123456701234567\"") - ); + }, + RPCExamples{ + HelpExampleCli("protx", "info \"0123456701234567012345670123456701234567012345670123456701234567\"") + }, + }.ToString()); } static UniValue protx_info(const JSONRPCRequest& request) @@ -1128,10 +1137,12 @@ static void protx_diff_help() RPCHelpMan{"protx diff", "\nCalculates a diff between two deterministic masternode lists. The result also contains proof data.\n", { - {"baseBlock", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The starting block height."}, - {"block", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The ending block height."}, - }} - .ToString()); + {"baseBlock", RPCArg::Type::NUM, RPCArg::Optional::NO, "The starting block height."}, + {"block", RPCArg::Type::NUM, RPCArg::Optional::NO, "The ending block height."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static uint256 ParseBlock(const UniValue& v, std::string strName) EXCLUSIVE_LOCKS_REQUIRED(cs_main) @@ -1174,27 +1185,28 @@ static UniValue protx_diff(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"protx", "Set of commands to execute ProTx related actions.\n" - "To get help on individual commands, use \"help protx command\".\n", + "To get help on individual commands, use \"help protx command\".\n" + "\nAvailable commands:\n" +#ifdef ENABLE_WALLET + " register - Create and send ProTx to network\n" + " register_fund - Fund, create and send ProTx to network\n" + " register_prepare - Create an unsigned ProTx\n" + " register_submit - Sign and submit a ProTx\n" +#endif + " list - List ProTxs\n" + " info - Return information about a ProTx\n" +#ifdef ENABLE_WALLET + " update_service - Create and send ProUpServTx to network\n" + " update_registrar - Create and send ProUpRegTx to network\n" + " revoke - Create and send ProUpRevTx to network\n" +#endif + " diff - Calculate a diff and a proof between two masternode lists\n", { - {"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"}, - }} - .ToString() + - "\nAvailable commands:\n" -#ifdef ENABLE_WALLET - " register - Create and send ProTx to network\n" - " register_fund - Fund, create and send ProTx to network\n" - " register_prepare - Create an unsigned ProTx\n" - " register_submit - Sign and submit a ProTx\n" -#endif - " list - List ProTxs\n" - " info - Return information about a ProTx\n" -#ifdef ENABLE_WALLET - " update_service - Create and send ProUpServTx to network\n" - " update_registrar - Create and send ProUpRegTx to network\n" - " revoke - Create and send ProUpRevTx to network\n" -#endif - " diff - Calculate a diff and a proof between two masternode lists\n" - ); + {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue protx(const JSONRPCRequest& request) @@ -1237,15 +1249,17 @@ static void bls_generate_help() throw std::runtime_error( RPCHelpMan{"bls generate", "\nReturns a BLS secret/public key pair.\n", - {}}.ToString() + - "\nResult:\n" + {}, + RPCResult{ "{\n" " \"secret\": \"xxxx\", (string) BLS secret key\n" " \"public\": \"xxxx\", (string) BLS public key\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("bls generate", "") - ); + }, + RPCExamples{ + HelpExampleCli("bls generate", "") + }, + }.ToString()); } static UniValue bls_generate(const JSONRPCRequest& request) @@ -1269,17 +1283,18 @@ static void bls_fromsecret_help() RPCHelpMan{"bls fromsecret", "\nParses a BLS secret key and returns the secret/public key pair.\n", { - {"secret", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The BLS secret key"}, - }} - .ToString() + - "\nResult:\n" + {"secret", RPCArg::Type::STR, RPCArg::Optional::NO, "The BLS secret key"}, + }, + RPCResult{ "{\n" " \"secret\": \"xxxx\", (string) BLS secret key\n" " \"public\": \"xxxx\", (string) BLS public key\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("bls fromsecret", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f") - ); + }, + RPCExamples{ + HelpExampleCli("bls fromsecret", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f") + }, + }.ToString()); } static UniValue bls_fromsecret(const JSONRPCRequest& request) @@ -1304,15 +1319,16 @@ static UniValue bls_fromsecret(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"bls", "Set of commands to execute BLS related actions.\n" - "To get help on individual commands, use \"help bls command\".\n", + "To get help on individual commands, use \"help bls command\".\n" + "\nAvailable commands:\n" + " generate - Create a BLS secret/public key pair\n" + " fromsecret - Parse a BLS secret key and return the secret/public key pair\n", { - {"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"}, - }} - .ToString() + - "\nAvailable commands:\n" - " generate - Create a BLS secret/public key pair\n" - " fromsecret - Parse a BLS secret key and return the secret/public key pair\n" - ); + {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue _bls(const JSONRPCRequest& request) diff --git a/src/rpc/rpcquorums.cpp b/src/rpc/rpcquorums.cpp index 083aec82ee..2785693bbc 100644 --- a/src/rpc/rpcquorums.cpp +++ b/src/rpc/rpcquorums.cpp @@ -29,21 +29,22 @@ static void quorum_list_help() RPCHelpMan{"quorum list", "List of on-chain quorums\n", { - {"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "Number of quorums to list. Will list active quorums if \"count\" is not specified."}, - }} - .ToString() + - "\nResult:\n" + {"count", RPCArg::Type::NUM, /* default */ "", "Number of quorums to list. Will list active quorums if \"count\" is not specified."}, + }, + RPCResult{ "{\n" " \"quorumName\" : [ (array of strings) List of quorum hashes per some quorum type.\n" " \"quorumHash\" (string) Quorum hash. Note: most recent quorums come first.\n" " ,...\n" " ],\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("quorum", "list") + }, + RPCExamples{ + HelpExampleCli("quorum", "list") + HelpExampleCli("quorum", "list 10") + HelpExampleRpc("quorum", "list, 10") - ); + }, + }.ToString()); } static UniValue quorum_list(const JSONRPCRequest& request) @@ -85,11 +86,13 @@ static void quorum_info_help() RPCHelpMan{"quorum info", "Return information about a quorum\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"quorumHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Block hash of quorum."}, - {"includeSkShare", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "", "Include secret key share in output."}, - }} - .ToString()); + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Block hash of quorum."}, + {"includeSkShare", RPCArg::Type::BOOL, /* default */ "", "Include secret key share in output."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue BuildQuorumInfo(const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare) @@ -159,11 +162,13 @@ static void quorum_dkgstatus_help() "Return the status of the current DKG process.\n" "Works only when SPORK_17_QUORUM_DKG_ENABLED spork is ON.\n", { - {"detail_level", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", + {"detail_level", RPCArg::Type::NUM, /* default */ "0", "Detail level of output.\n" "0=Only show counts. 1=Show member indexes. 2=Show member's ProTxHashes."}, - }} - .ToString()); + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue quorum_dkgstatus(const JSONRPCRequest& request) @@ -242,12 +247,14 @@ static void quorum_memberof_help() RPCHelpMan{"quorum memberof", "Checks which quorums the given masternode is a member of.\n", { - {"proTxHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "ProTxHash of the masternode."}, - {"scanQuorumsCount", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", + {"proTxHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "ProTxHash of the masternode."}, + {"scanQuorumsCount", RPCArg::Type::NUM, /* default */ "", "Number of quorums to scan for. If not specified,\n" "the active quorum count for each specific quorum type is used."}, - }} - .ToString()); + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue quorum_memberof(const JSONRPCRequest& request) @@ -301,15 +308,17 @@ static void quorum_sign_help() RPCHelpMan{"quorum sign", "Threshold-sign a message\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - {"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."}, - {"quorumHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The quorum identifier."}, - {"submit", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Submits the signature share to the network if this is true."}, - }} - .ToString() + + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + {"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."}, + {"quorumHash", RPCArg::Type::STR_HEX, /* default */ "", "The quorum identifier."}, + {"submit", RPCArg::Type::BOOL, /* default */ "true", "Submits the signature share to the network if this is true."}, + }, + RPCResult{ "\nReturns an object containing the signature share if this is false.\n" - ); + }, + RPCExamples{""}, + }.ToString()); } static void quorum_verify_help() @@ -318,18 +327,20 @@ static void quorum_verify_help() RPCHelpMan{"quorum verify", "Test if a quorum signature is valid for a request id and a message hash\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - {"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."}, - {"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "Quorum signature to verify."}, - {"quorumHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + {"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."}, + {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "Quorum signature to verify."}, + {"quorumHash", RPCArg::Type::STR_HEX, /* default */ "", "The quorum identifier.\n" "Set to \"\" if you want to specify signHeight instead."}, - {"signHeight", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", + {"signHeight", RPCArg::Type::NUM, /* default */ "", "The height at which the message was signed.\n" "Only works when quorumHash is \"\"."}, - }} - .ToString()); + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static void quorum_hasrecsig_help() @@ -338,11 +349,13 @@ static void quorum_hasrecsig_help() RPCHelpMan{"quorum hasrecsig", "Test if a valid recovered signature is present\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - {"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."}, - }} - .ToString()); + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + {"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static void quorum_getrecsig_help() @@ -351,11 +364,13 @@ static void quorum_getrecsig_help() RPCHelpMan{"quorum getrecsig", "Get a recovered signature\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - {"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."}, - }} - .ToString()); + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + {"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static void quorum_isconflicting_help() @@ -364,11 +379,13 @@ static void quorum_isconflicting_help() RPCHelpMan{"quorum isconflicting", "Test if a conflict exists\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - {"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."}, - }} - .ToString()); + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + {"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue quorum_sigs_cmd(const JSONRPCRequest& request) @@ -496,10 +513,12 @@ static void quorum_selectquorum_help() RPCHelpMan{"quorum selectquorum", "Returns the quorum that would/should sign a request\n", { - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."}, - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - }} - .ToString()); + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."}, + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue quorum_selectquorum(const JSONRPCRequest& request) @@ -540,10 +559,12 @@ static void quorum_dkgsimerror_help() "This enables simulation of errors and malicious behaviour in the DKG. Do NOT use this on mainnet\n" "as you will get yourself very likely PoSe banned for this.\n", { - {"type", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "Error type."}, - {"rate", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Rate at which to simulate this error type."}, - }} - .ToString()); + {"type", RPCArg::Type::STR, RPCArg::Optional::NO, "Error type."}, + {"rate", RPCArg::Type::NUM, RPCArg::Optional::NO, "Rate at which to simulate this error type."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue quorum_dkgsimerror(const JSONRPCRequest& request) @@ -570,17 +591,19 @@ static void quorum_getdata_help() RPCHelpMan{"quorum getdata", "Send a QGETDATA message to the specified peer.\n", { - {"nodeId", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The internal nodeId of the peer to request quorum data from."}, - {"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The quorum type related to the quorum data being requested."}, - {"quorumHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The quorum hash related to the quorum data being requested."}, - {"dataMask", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", + {"nodeId", RPCArg::Type::NUM, RPCArg::Optional::NO, "The internal nodeId of the peer to request quorum data from."}, + {"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "The quorum type related to the quorum data being requested."}, + {"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The quorum hash related to the quorum data being requested."}, + {"dataMask", RPCArg::Type::NUM, RPCArg::Optional::NO, "Specify what data to request.\n" "Possible values: 1 - Request quorum verification vector\n" "2 - Request encrypted contributions for member defined by \"proTxHash\". \"proTxHash\" must be specified if this option is used.\n" "3 - Request both, 1 and 2"}, - {"proTxHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The proTxHash the contributions will be requested for. Must be member of the specified LLMQ."}, - }} - .ToString()); + {"proTxHash", RPCArg::Type::STR_HEX, /* default */ "", "The proTxHash the contributions will be requested for. Must be member of the specified LLMQ."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue quorum_getdata(const JSONRPCRequest& request) @@ -619,25 +642,26 @@ static UniValue quorum_getdata(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"quorum", "Set of commands for quorums/LLMQs.\n" - "To get help on individual commands, use \"help quorum command\".\n", + "To get help on individual commands, use \"help quorum command\".\n" + "\nAvailable commands:\n" + " list - List of on-chain quorums\n" + " info - Return information about a quorum\n" + " dkgsimerror - Simulates DKG errors and malicious behavior\n" + " dkgstatus - Return the status of the current DKG process\n" + " memberof - Checks which quorums the given masternode is a member of\n" + " sign - Threshold-sign a message\n" + " verify - Test if a quorum signature is valid for a request id and a message hash\n" + " hasrecsig - Test if a valid recovered signature is present\n" + " getrecsig - Get a recovered signature\n" + " isconflicting - Test if a conflict exists\n" + " selectquorum - Return the quorum that would/should sign a request\n" + " getdata - Request quorum data from other masternodes in the quorum\n", { - {"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"}, - }} - .ToString() + - "\nAvailable commands:\n" - " list - List of on-chain quorums\n" - " info - Return information about a quorum\n" - " dkgsimerror - Simulates DKG errors and malicious behavior\n" - " dkgstatus - Return the status of the current DKG process\n" - " memberof - Checks which quorums the given masternode is a member of\n" - " sign - Threshold-sign a message\n" - " verify - Test if a quorum signature is valid for a request id and a message hash\n" - " hasrecsig - Test if a valid recovered signature is present\n" - " getrecsig - Get a recovered signature\n" - " isconflicting - Test if a conflict exists\n" - " selectquorum - Return the quorum that would/should sign a request\n" - " getdata - Request quorum data from other masternodes in the quorum\n" - ); + {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue _quorum(const JSONRPCRequest& request) @@ -678,11 +702,13 @@ static void verifychainlock_help() RPCHelpMan{"verifychainlock", "Test if a quorum signature is valid for a ChainLock.\n", { - {"blockHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash of the ChainLock."}, - {"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The signature of the ChainLock."}, - {"blockHeight", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The height of the ChainLock. There will be an internal lookup of \"blockHash\" if this is not provided."}, - }} - .ToString()); + {"blockHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash of the ChainLock."}, + {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature of the ChainLock."}, + {"blockHeight", RPCArg::Type::NUM, /* default */ "", "The height of the ChainLock. There will be an internal lookup of \"blockHash\" if this is not provided."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue verifychainlock(const JSONRPCRequest& request) @@ -720,12 +746,14 @@ static void verifyislock_help() RPCHelpMan{"verifyislock", "Test if a quorum signature is valid for an InstantSend Lock\n", { - {"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."}, - {"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id."}, - {"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The InstantSend Lock signature to verify."}, - {"maxHeight", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The maximum height to search quorums from."}, - }} - .ToString()); + {"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."}, + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id."}, + {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The InstantSend Lock signature to verify."}, + {"maxHeight", RPCArg::Type::NUM, /* default */ "", "The maximum height to search quorums from."}, + }, + RPCResults{}, + RPCExamples{""}, + }.ToString()); } static UniValue verifyislock(const JSONRPCRequest& request) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 90cad647f3..ecccf0f552 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -677,18 +677,19 @@ UniValue importelectrumwallet(const JSONRPCRequest& request) RPCHelpMan{"importselectrumwallet", "\nImports keys from an Electrum wallet export file (.csv or .json)\n", { - {"filename", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The Electrum wallet export file, should be in csv or json format"}, - {"index", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Rescan the wallet for transactions starting from this block index"}, - }} - .ToString() + - "\nExamples:\n" + {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The Electrum wallet export file, should be in csv or json format"}, + {"index", RPCArg::Type::NUM, /* default */ "0", "Rescan the wallet for transactions starting from this block index"}, + }, + RPCResults{}, + RPCExamples{ "\nImport the wallet\n" + HelpExampleCli("importelectrumwallet", "\"test.csv\"") + HelpExampleCli("importelectrumwallet", "\"test.json\"") + "\nImport using the json rpc call\n" + HelpExampleRpc("importelectrumwallet", "\"test.csv\"") + HelpExampleRpc("importelectrumwallet", "\"test.json\"") - ); + }, + }.ToString()); if (fPruneMode) throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode"); @@ -869,18 +870,19 @@ UniValue dumphdinfo(const JSONRPCRequest& request) throw std::runtime_error( RPCHelpMan{"dumphdinfo", "Returns an object containing sensitive private info about this HD wallet.\n", - {}} - .ToString() + - "\nResult:\n" + {}, + RPCResult{ "{\n" " \"hdseed\": \"seed\", (string) The HD seed (bip32, in hex)\n" " \"mnemonic\": \"words\", (string) The mnemonic for this HD wallet (bip39, english words) \n" " \"mnemonicpassphrase\": \"passphrase\", (string) The mnemonic passphrase for this HD wallet (bip39)\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("dumphdinfo", "") + }, + RPCExamples{ + HelpExampleCli("dumphdinfo", "") + HelpExampleRpc("dumphdinfo", "") - ); + }, + }.ToString()); LOCK(pwallet->cs_wallet); @@ -1525,7 +1527,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) }, RPCResult{ "\nResponse is an array with the same size as the input that has the execution result :\n" - " [{\"success\": true}, {\"success\": true, \"warnings\": [\"Ignoring irrelevant private key\"]}, {\"success\": false, \"error\": {\"code\": -1, \"message\": \"Internal Server Error\"}}, ...]\n"); + " [{\"success\": true}, {\"success\": true, \"warnings\": [\"Ignoring irrelevant private key\"]}, {\"success\": false, \"error\": {\"code\": -1, \"message\": \"Internal Server Error\"}}, ...]\n" }, RPCExamples{ HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"\" }, \"timestamp\":1455191478 }, " diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 55fc3fa844..df610936c3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -511,20 +511,21 @@ static UniValue listaddressbalances(const JSONRPCRequest& request) RPCHelpMan{"listaddressbalances", "\nLists addresses of this wallet and their balances\n", { - {"minamount", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Minimum balance in " + CURRENCY_UNIT + " an address should have to be shown in the list"}, - }} - .ToString() + - "\nResult:\n" + {"minamount", RPCArg::Type::NUM, /* default */ "0", "Minimum balance in " + CURRENCY_UNIT + " an address should have to be shown in the list"}, + }, + RPCResult{ "{\n" " \"address\": amount, (string) The dash address and the amount in " + CURRENCY_UNIT + "\n" " ,...\n" "}\n" - "\nExamples:\n" - + HelpExampleCli("listaddressbalances", "") + }, + RPCExamples{ + HelpExampleCli("listaddressbalances", "") + HelpExampleCli("listaddressbalances", "10") + HelpExampleRpc("listaddressbalances", "") + HelpExampleRpc("listaddressbalances", "10") - ); + } + }.ToString()); auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); @@ -2469,15 +2470,16 @@ static UniValue setcoinjoinrounds(const JSONRPCRequest& request) RPCHelpMan{"setcoinjoinrounds", "\nSet the number of rounds for CoinJoin.\n", { - {"rounds", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", + {"rounds", RPCArg::Type::NUM, RPCArg::Optional::NO, "The default number of rounds is " + std::to_string(DEFAULT_COINJOIN_ROUNDS) + " Cannot be more than " + std::to_string(MAX_COINJOIN_ROUNDS) + " nor less than " + std::to_string(MIN_COINJOIN_ROUNDS)}, - }} - .ToString() + - "\nExamples:\n" - + HelpExampleCli("setcoinjoinrounds", "4") + }, + RPCResults{}, + RPCExamples{ + HelpExampleCli("setcoinjoinrounds", "4") + HelpExampleRpc("setcoinjoinrounds", "16") - ); + }, + }.ToString()); int nRounds = request.params[0].get_int(); @@ -2501,15 +2503,16 @@ static UniValue setcoinjoinamount(const JSONRPCRequest& request) RPCHelpMan{"setcoinjoinamount", "\nSet the goal amount in " + CURRENCY_UNIT + " for CoinJoin.\n", { - {"amount", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", + {"amount", RPCArg::Type::NUM, RPCArg::Optional::NO, "The default amount is " + std::to_string(DEFAULT_COINJOIN_AMOUNT) + " Cannot be more than " + std::to_string(MAX_COINJOIN_AMOUNT) + " nor less than " + std::to_string(MIN_COINJOIN_AMOUNT)}, - }} - .ToString() + - "\nExamples:\n" - + HelpExampleCli("setcoinjoinamount", "500") + }, + RPCResults{}, + RPCExamples{ + HelpExampleCli("setcoinjoinamount", "500") + HelpExampleRpc("setcoinjoinamount", "208") - ); + }, + }.ToString()); int nAmount = request.params[0].get_int(); @@ -2720,16 +2723,18 @@ static UniValue upgradetohd(const JSONRPCRequest& request) "\nUpgrades non-HD wallets to HD.\n" "\nWarning: You will need to make a new backup of your wallet after setting the HD wallet mnemonic.\n", { - {"mnemonic", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Mnemonic as defined in BIP39 to use for the new HD wallet. Use an empty string \"\" to generate a new random mnemonic."}, - {"mnemonicpassphrase", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Optional mnemonic passphrase as defined in BIP39"}, - {"walletpassphrase", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "If your wallet is encrypted you must have your wallet passphrase here. If your wallet is not encrypted specifying wallet passphrase will trigger wallet encryption."}, - }} - .ToString() + - "\nExamples:\n" - + HelpExampleCli("upgradetohd", "") + {"mnemonic", RPCArg::Type::STR, /* default */ "", "Mnemonic as defined in BIP39 to use for the new HD wallet. Use an empty string \"\" to generate a new random mnemonic."}, + {"mnemonicpassphrase", RPCArg::Type::STR, /* default */ "", "Optional mnemonic passphrase as defined in BIP39"}, + {"walletpassphrase", RPCArg::Type::STR, /* default */ "", "If your wallet is encrypted you must have your wallet passphrase here. If your wallet is not encrypted specifying wallet passphrase will trigger wallet encryption."}, + }, + RPCResults{}, + RPCExamples{ + HelpExampleCli("upgradetohd", "") + HelpExampleCli("upgradetohd", "\"mnemonicword1 ... mnemonicwordN\"") + HelpExampleCli("upgradetohd", "\"mnemonicword1 ... mnemonicwordN\" \"mnemonicpassphrase\"") - + HelpExampleCli("upgradetohd", "\"mnemonicword1 ... mnemonicwordN\" \"mnemonicpassphrase\" \"walletpassphrase\"")); + + HelpExampleCli("upgradetohd", "\"mnemonicword1 ... mnemonicwordN\" \"mnemonicpassphrase\" \"walletpassphrase\"") + }, + }.ToString()); LOCK2(cs_main, pwallet->cs_wallet);