diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -17,7 +17,7 @@ throw std::runtime_error( RPCHelpMan{ "getexcessiveblock", "\nReturn the excessive block size.", {}} - .ToStringWithArgs() + + .ToString() + "\nResult\n" " excessiveBlockSize (integer) block size in bytes\n" "\nExamples:\n" + @@ -45,7 +45,7 @@ "Excessive block size in bytes. Must be greater than " + std::to_string(LEGACY_MAX_BLOCK_SIZE) + "."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult\n" " blockSize (integer) excessive block size in bytes\n" "\nExamples:\n" + diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -18,7 +18,7 @@ RPCHelpMan{"getavalanchekey", "\nReturns the key used to sign avalanche messages.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleRpc("getavalanchekey", "")); } @@ -42,7 +42,7 @@ {"publickey", RPCArg::Type::STR_HEX, /* opt */ false, /* default_value */ "", "The public key of the node."}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleRpc("addavalanchepeer", "5")); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -159,7 +159,7 @@ "getblockcount", "\nReturns the number of blocks in the longest blockchain.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "n (numeric) The current block count\n" "\nExamples:\n" + @@ -179,7 +179,7 @@ "\nReturns the hash of the best (tip) block in the " "longest blockchain.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"hex\" (string) the block hash hex-encoded\n" "\nExamples:\n" + @@ -198,7 +198,7 @@ RPCHelpMan{"getfinalizedblockhash", "\nReturns the hash of the currently finalized block\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"hex\" (string) the block hash hex-encoded\n"); } @@ -234,7 +234,7 @@ "Time in milliseconds to wait for a response. 0 " "indicates no timeout."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object)\n" " \"hash\" : { (string) The blockhash\n" @@ -291,7 +291,7 @@ "Time in milliseconds to wait for a response. 0 " "indicates no timeout."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object)\n" " \"hash\" : { (string) The blockhash\n" @@ -353,7 +353,7 @@ "Time in milliseconds to wait for a response. 0 " "indicates no timeout."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object)\n" " \"hash\" : { (string) The blockhash\n" @@ -403,7 +403,7 @@ "\nWaits for the validation interface queue to catch up on " "everything that was there when we entered this function.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("syncwithvalidationinterfacequeue", "") + HelpExampleRpc("syncwithvalidationinterfacequeue", "")); @@ -420,7 +420,7 @@ "\nReturns the proof-of-work difficulty as a " "multiple of the minimum difficulty.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "n.nnn (numeric) the proof-of-work " "difficulty as a multiple of the minimum " @@ -571,7 +571,7 @@ "True for a json object, false for array of " "transaction ids"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult: (for verbose = false):\n" "[ (json array of string)\n" " \"transactionid\" (string) The transaction id\n" @@ -613,7 +613,7 @@ "True for a json object, false for array of " "transaction ids"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult (for verbose = false):\n" "[ (json array of strings)\n" " \"transactionid\" (string) The transaction id of an " @@ -689,7 +689,7 @@ "True for a json object, false for array of " "transaction ids"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult (for verbose = false):\n" "[ (json array of strings)\n" " \"transactionid\" (string) The transaction id of an " @@ -758,7 +758,7 @@ /* default_val */ "", "The transaction id (must be in mempool)"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object)\n" + EntryDescriptionString() + @@ -795,7 +795,7 @@ {"height", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The height index"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"hash\" (string) The block hash\n" "\nExamples:\n" + @@ -832,7 +832,7 @@ /* default_val */ "true", "true for a json object, false for the hex-encoded data"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult (for verbose = true):\n" "{\n" " \"hash\" : \"hash\", (string) the block hash (same as " @@ -940,7 +940,7 @@ "0 for hex-encoded data, 1 for a json object, and 2 for " "json object with transaction data"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult (for verbosity = 0):\n" "\"data\" (string) A string that is serialized, " "hex-encoded data for block 'hash'.\n" @@ -1115,7 +1115,7 @@ " to prune blocks whose block time is at " "least 2 hours older than the provided timestamp."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "n (numeric) Height of the last block pruned.\n" "\nExamples:\n" + @@ -1179,7 +1179,7 @@ "output set.\n" "Note this call may take some time.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"height\":n, (numeric) The current block height (index)\n" @@ -1235,7 +1235,7 @@ "Whether to include the mempool. Note that an unspent " "output that is spent in the mempool won't appear."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"bestblock\" : \"hash\", (string) the block hash\n" @@ -1327,7 +1327,7 @@ /* default_val */ strprintf("%d, 0=all", nCheckDepth), "The number of blocks to check."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "true|false (boolean) Verified or not\n" "\nExamples:\n" + @@ -1418,7 +1418,7 @@ "Returns an object containing various state info " "regarding blockchain processing.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"chain\": \"xxxx\", (string) current network name " @@ -1565,7 +1565,7 @@ "Return information about all known tips in the block tree, " "including the main chain as well as orphaned branches.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" @@ -1707,7 +1707,7 @@ "\nReturns details on the active state of the TX memory " "pool.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"loaded\": true|false (boolean) True if the mempool is " @@ -1749,7 +1749,7 @@ /* default_val */ "", "the hash of the block to mark as precious"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("preciousblock", "\"blockhash\"") + @@ -1791,7 +1791,7 @@ /* default_val */ "", "the hash of the block to mark as invalid"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("finalizeblock", "\"blockhash\"") + @@ -1835,7 +1835,7 @@ /* default_val */ "", "the hash of the block to mark as invalid"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("invalidateblock", "\"blockhash\"") + @@ -1876,7 +1876,7 @@ {"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hash of the block to park"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("parkblock", "\"blockhash\"") + @@ -1923,7 +1923,7 @@ /* default_val */ "", "the hash of the block to reconsider"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("reconsiderblock", "\"blockhash\"") + @@ -1964,7 +1964,7 @@ {"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hash of the block to unpark"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("unparkblock", "\"blockhash\"") + @@ -2009,7 +2009,7 @@ /* default_val */ "", "The hash of the block that ends the window."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"time\": xxxxx, (numeric) The " @@ -2157,7 +2157,7 @@ }, "stats"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object)\n" " \"avgfee\": x.xxx, (numeric) Average fee in the block\n" @@ -2432,7 +2432,7 @@ "\nDumps the mempool to disk. It will fail until the " "previous dump is fully loaded.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("savemempool", "") + HelpExampleRpc("savemempool", "")); } @@ -2588,7 +2588,7 @@ }, "[scanobjects,...]"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"unspents\": [\n" diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -104,7 +104,7 @@ /* default_val */ "-1", "To estimate at the time of the given height."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "x (numeric) Hashes per second estimated\n" "\nExamples:\n" + @@ -205,7 +205,7 @@ /* default_val */ "1000000", "How many iterations to try."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[ blockhashes ] (array) hashes of blocks generated\n" "\nExamples:\n" @@ -241,7 +241,7 @@ "\nReturns a json object containing mining-related " "information.", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"blocks\": nnn, (numeric) The current block\n" @@ -306,7 +306,7 @@ " considers the transaction as it would " "have paid a higher (or lower) fee."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "true (boolean) Returns true\n" "\nExamples:\n" + @@ -402,7 +402,7 @@ }, "\"template_request\""}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"version\" : n, (numeric) The preferred " @@ -747,7 +747,7 @@ "dummy value, for compatibility with BIP22. This " "value is ignored."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("submitblock", "\"mydata\"") + @@ -815,7 +815,7 @@ {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hex-encoded block header data"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "None" "\nExamples:\n" + @@ -857,7 +857,7 @@ "\nEstimates the approximate fee per kilobyte needed " "for a transaction\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "n (numeric) estimated fee-per-kilobyte\n" "\nExample:\n" + diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -40,7 +40,7 @@ {"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The bitcoin address to validate"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"isvalid\" : true|false, (boolean) If the address is " @@ -106,7 +106,7 @@ /* default_val */ "", "The hex-encoded public key"}, }}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"address\":\"multisigaddress\", (string) The value of the new " @@ -187,7 +187,7 @@ {"message", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The message that was signed."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "true|false (boolean) If the signature is verified or not.\n" "\nExamples:\n" @@ -258,7 +258,7 @@ /* default_val */ "", "The message to create a signature of."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"signature\" (string) The signature of the message " "encoded in base 64\n" @@ -306,7 +306,7 @@ /* default_val */ "", "Unix seconds-since-epoch timestamp\n" " Pass 0 to go back to using the system time."}, - }}.ToStringWithArgs()); + }}.ToString()); } if (!config.GetChainParams().MineBlocksOnDemand()) { @@ -379,7 +379,7 @@ "low-level heap state (only available if compiled with " "glibc 2.10+)."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult (mode \"stats\"):\n" "{\n" " \"locked\": { (json object) Information about " @@ -487,7 +487,7 @@ "the valid logging category"}, }}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object where keys are the logging " "categories, and values indicates its status\n" @@ -552,7 +552,7 @@ "has argument conversion enabled in the client-side table in " "bitcoin-cli and the GUI. There is no server-side difference.", {}} - .ToStringWithArgs() + + .ToString() + ""); } diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -33,7 +33,7 @@ RPCHelpMan{"getconnectioncount", "\nReturns the number of connections to other nodes.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "n (numeric) The connection count\n" "\nExamples:\n" + @@ -62,7 +62,7 @@ "Ping command is handled in queue with all other commands, so " "it measures processing backlog, not just network ping.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("ping", "") + HelpExampleRpc("ping", "")); } @@ -86,7 +86,7 @@ "\nReturns data about each connected network node as a " "json array of objects.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" @@ -273,7 +273,7 @@ "node from the list, 'onetry' to try a connection to the " "node once"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") + HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")); @@ -325,7 +325,7 @@ /* default_val */ "", "The node ID (see getpeerinfo for node IDs)"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") + HelpExampleCli("disconnectnode", "\"\" 1") + @@ -380,7 +380,7 @@ "If provided, return information about this " "specific node, otherwise all nodes are returned."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" @@ -456,7 +456,7 @@ "bytes in, bytes out,\n" "and current time.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"totalbytesrecv\": n, (numeric) Total bytes received\n" @@ -539,7 +539,7 @@ "Returns an object containing various state info " "regarding P2P networking.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"version\": xxxxx, (numeric) the server " @@ -672,7 +672,7 @@ "If set, the bantime must be an absolute timestamp in " "seconds since epoch (Jan 1 1970 GMT)"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") + HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") + @@ -749,7 +749,7 @@ if (request.fHelp || request.params.size() != 0) { throw std::runtime_error( RPCHelpMan{"listbanned", "\nList all banned IPs/Subnets.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("listbanned", "") + HelpExampleRpc("listbanned", "")); } @@ -782,7 +782,7 @@ if (request.fHelp || request.params.size() != 0) { throw std::runtime_error( RPCHelpMan{"clearbanned", "\nClear all banned IPs.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("clearbanned", "") + HelpExampleRpc("clearbanned", "")); } @@ -807,7 +807,7 @@ {"state", RPCArg::Type::BOOL, /* opt */ false, /* default_val */ "", "true to enable networking, false to disable"}, - }}.ToStringWithArgs()); + }}.ToString()); } if (!g_connman) { @@ -837,7 +837,7 @@ std::to_string(ADDRMAN_GETADDR_MAX_PCT) + "% of all known addresses."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -99,7 +99,7 @@ /* default_val */ "", "The block in which to look for the transaction"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult (if verbose is not set or set to false):\n" "\"data\" (string) The serialized, hex-encoded data for " "'txid'\n" @@ -276,7 +276,7 @@ "If specified, looks for txid in the block with this " "hash"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"data\" (string) A string that is a serialized, " "hex-encoded data for the proof.\n"); @@ -385,7 +385,7 @@ /* default_val */ "", "The hex-encoded proof generated by gettxoutproof"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\"txid\"] (array, strings) The txid(s) which the proof " "commits to, or empty array if the proof can not be validated.\n"); @@ -634,7 +634,7 @@ "Raw locktime. Non-0 value also locktime-activates " "inputs"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"transaction\" (string) hex string of the " "transaction\n" @@ -678,7 +678,7 @@ {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction hex string"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"txid\" : \"id\", (string) The transaction id\n" @@ -751,7 +751,7 @@ {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hex-encoded script"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"asm\":\"asm\", (string) Script public key\n" @@ -837,7 +837,7 @@ }, }, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"hex\" (string) The hex-encoded raw transaction with " "signature(s)\n" @@ -1163,7 +1163,7 @@ " \"NONE|FORKID|ANYONECANPAY\"\n" " \"SINGLE|FORKID|ANYONECANPAY\""}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"hex\" : \"value\", (string) The hex-encoded " @@ -1235,7 +1235,7 @@ {"allowhighfees", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Allow high fees"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"hex\" (string) The transaction hash in hex\n" "\nExamples:\n" @@ -1298,7 +1298,7 @@ {"allowhighfees", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Allow high fees"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[ (array) The result of the mempool acceptance " "test for each raw transaction in the input array.\n" @@ -1403,7 +1403,7 @@ {"psbt", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The PSBT base64 string"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"tx\" : { (json object) The decoded " @@ -1693,7 +1693,7 @@ }, }, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" " \"psbt\" (string) The base64-encoded partially signed " "transaction\n" @@ -1762,7 +1762,7 @@ "the complete transaction in normal network " "serialization instead of the PSBT."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"psbt\" : \"value\", (string) The base64-encoded " @@ -1902,7 +1902,7 @@ "Raw locktime. Non-0 value also locktime-activates " "inputs"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" " \"psbt\" (string) The resulting raw transaction " "(base64-encoded string)\n" @@ -1964,7 +1964,7 @@ " will continue. If false, " "RPC will fail if any signatures are present."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" " \"psbt\" (string) The resulting raw transaction " "(base64-encoded string)\n" diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -291,7 +291,7 @@ {"command", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The command to get help on"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"text\" (string) The help text\n"); } diff --git a/src/rpc/util.h b/src/rpc/util.h --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -87,26 +87,6 @@ assert(type == Type::ARR || type == Type::OBJ); } - // Remove once PR14796 backport is completed - RPCArg(const std::string &name, const Type &type, const bool optional, - const std::string &oneline_description = "") - : m_name{name}, m_type{type}, m_optional{optional}, - m_oneline_description{oneline_description} { - assert(type != Type::ARR && type != Type::OBJ); - } - - // Remove once PR14796 backport is completed - RPCArg(const std::string &name, const Type &type, - const std::vector &inner, const bool optional, - const std::string &oneline_description = "") - : m_name{name}, m_type{type}, m_inner{inner}, m_optional{optional}, - m_oneline_description{oneline_description} { - assert(type == Type::ARR || type == Type::OBJ); - } - - // Remove once PR14796 backport is completed - std::string ToString() const; - /** * Return the type string of the argument. * Set oneline to allow it to be overrided by a custom oneline type string @@ -125,10 +105,6 @@ * optional nor required. */ std::string ToDescriptionString(bool implicitly_required = false) const; - -private: - // Remove once PR14796 backport is completed - std::string ToStringObj() const; }; class RPCHelpMan { @@ -139,9 +115,6 @@ std::string ToString() const; - // Remove once PR14796 backport is completed - std::string ToStringWithArgs() const; - private: const std::string m_name; const std::string m_description; diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -254,42 +254,9 @@ } }; -// Remove once PR14796 backport is completed std::string RPCHelpMan::ToString() const { std::string ret; - ret += m_name; - bool is_optional{false}; - for (const auto &arg : m_args) { - ret += " "; - if (arg.m_optional) { - if (!is_optional) { - ret += "( "; - } - is_optional = true; - } else { - // Currently we still support unnamed arguments, so any argument - // following an optional argument must also be optional If support - // for positional arguments is deprecated in the future, remove this - // line - assert(!is_optional); - } - ret += arg.ToString(); - } - if (is_optional) { - ret += " )"; - } - ret += "\n"; - - ret += m_description; - - return ret; -} - -// Rename to ToString() once PR14796 is completed -std::string RPCHelpMan::ToStringWithArgs() const { - std::string ret; - // Oneline summary ret += m_name; bool was_optional{false}; @@ -399,36 +366,6 @@ return ret; } -// Remove once PR14796 backport is completed -std::string RPCArg::ToStringObj() const { - std::string res = "\"" + m_name + "\":"; - switch (m_type) { - case Type::STR: - return res + "\"str\""; - case Type::STR_HEX: - return res + "\"hex\""; - case Type::NUM: - return res + "n"; - case Type::AMOUNT: - return res + "amount"; - case Type::BOOL: - return res + "bool"; - case Type::ARR: - res += "["; - for (const auto &i : m_inner) { - res += i.ToString() + ","; - } - return res + "...]"; - case Type::OBJ: - case Type::OBJ_USER_KEYS: - // Currently unused, so avoid writing dead code - assert(false); - - // no default case, so the compiler can warn about missing cases - } - assert(false); -} - std::string RPCArg::ToStringObj(const bool oneline) const { std::string res; res += "\""; @@ -465,50 +402,6 @@ assert(false); } -// Remove once PR14796 backport is completed -std::string RPCArg::ToString() const { - if (!m_oneline_description.empty()) { - return m_oneline_description; - } - - switch (m_type) { - case Type::STR_HEX: - case Type::STR: { - return "\"" + m_name + "\""; - } - case Type::NUM: - case Type::AMOUNT: - case Type::BOOL: { - return m_name; - } - case Type::OBJ: - case Type::OBJ_USER_KEYS: { - std::string res; - for (size_t i = 0; i < m_inner.size();) { - res += m_inner[i].ToStringObj(); - if (++i < m_inner.size()) { - res += ","; - } - } - if (m_type == Type::OBJ) { - return "{" + res + "}"; - } else { - return "{" + res + ",...}"; - } - } - case Type::ARR: { - std::string res; - for (const auto &i : m_inner) { - res += i.ToString() + ","; - } - return "[" + res + "...]"; - } - - // no default case, so the compiler can warn about missing cases - } - assert(false); -} - std::string RPCArg::ToString(const bool oneline) const { if (oneline && !m_oneline_description.empty()) { return m_oneline_description; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -116,7 +116,7 @@ /* default_val */ "true", "Rescan the wallet for transactions"}, }} - .ToStringWithArgs() + + .ToString() + "\nNote: This call can take minutes to complete if rescan is true, " "during that time, other rpc calls\n" "may report that the imported key exists but related transactions " @@ -225,7 +225,7 @@ "\nStops current wallet rescan triggered by " "an RPC call, e.g. by an importprivkey call.\n", {}} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" "\nImport a private key\n" + HelpExampleCli("importprivkey", "\"mykey\"") + @@ -312,7 +312,7 @@ /* default_val */ "false", "Add the P2SH version of the script as well"}, }} - .ToStringWithArgs() + + .ToString() + "\nNote: This call can take minutes to complete if rescan is true, " "during that time, other rpc calls\n" "may report that the imported address exists but related " @@ -419,7 +419,7 @@ /* default_val */ "", "The hex output from gettxoutproof that contains the " "transaction"}, - }}.ToStringWithArgs()); + }}.ToString()); } CMutableTransaction tx; @@ -497,7 +497,7 @@ /* default_val */ "", "The hex-encoded id of the transaction you are deleting"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1" "ce581bebf46446a512166eae762873" @@ -552,7 +552,7 @@ /* default_val */ "true", "Rescan the wallet for transactions"}, }} - .ToStringWithArgs() + + .ToString() + "\nNote: This call can take minutes to complete if rescan is true, " "during that time, other rpc calls\n" "may report that the imported pubkey exists but related " @@ -637,7 +637,7 @@ {"filename", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The wallet file"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" "\nDump the wallet\n" + HelpExampleCli("dumpwallet", "\"test\"") + "\nImport the wallet\n" + @@ -840,7 +840,7 @@ /* default_val */ "", "The bitcoin address for the private key"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"key\" (string) The private key\n" "\nExamples:\n" + @@ -901,7 +901,7 @@ "The filename with path (either absolute or relative to " "bitcoind)"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object)\n" " \"filename\" : { (string) The filename with full " @@ -1550,7 +1550,7 @@ }, "\"options\""}, }} - .ToStringWithArgs() + + .ToString() + "\nNote: This call can take minutes to complete if rescan is true, " "during that time, other rpc calls\n" "may report that the imported keys, addresses or scripts exists " diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -184,7 +184,7 @@ "label. The label does not need to exist, it will be " "created if there is no label by the given name."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"address\" (string) The new bitcoin address\n" "\nExamples:\n" + @@ -328,7 +328,7 @@ /* default_val */ "", "The label to assign to the address."}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + @@ -455,7 +455,7 @@ " The recipient will receive " "less bitcoins than you enter in the amount field."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + @@ -603,7 +603,7 @@ /* default_val */ "", "The message to create a signature of."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"signature\" (string) The signature of the message " "encoded in base 64\n" @@ -685,7 +685,7 @@ "Only include transactions confirmed at least this many " "times."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + @@ -784,7 +784,7 @@ "Only include transactions confirmed at least this " "many times."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + @@ -878,7 +878,7 @@ "Also include balance in watch-only addresses (see " "'importaddress')"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + @@ -1005,7 +1005,7 @@ }, }, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\"txid\" (string) The transaction id for the " "send. Only 1 transaction is created regardless of \n" @@ -1190,7 +1190,7 @@ /* default_val */ "", "A label to assign the addresses to."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"address\":\"multisigaddress\", (string) The value of the " @@ -1449,7 +1449,7 @@ /* default_val */ "", "If present, only return information on this address."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" @@ -1520,7 +1520,7 @@ "Whether to include watch-only addresses (see " "'importaddress')."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" @@ -1683,7 +1683,7 @@ "Include transactions to watch-only addresses (see " "'importaddress')"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[\n" " {\n" @@ -1868,7 +1868,7 @@ " " " (not guaranteed to work on pruned nodes)"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"transactions\": [\n" @@ -2063,7 +2063,7 @@ "Whether to include watch-only addresses in " "balance calculation and details[]"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"amount\" : x.xxx, (numeric) The transaction amount " @@ -2206,7 +2206,7 @@ {"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "\nExamples:\n" + HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084" @@ -2258,7 +2258,7 @@ {"destination", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The destination directory or file"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("backupwallet", "\"backup.dat\"") + HelpExampleRpc("backupwallet", "\"backup.dat\"")); } @@ -2296,7 +2296,7 @@ {"newsize", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "100", "The new keypool size"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("keypoolrefill", "") + HelpExampleRpc("keypoolrefill", "")); } @@ -2361,7 +2361,7 @@ "The time to keep the decryption key in seconds; capped " "at 100000000 (~3 years)."}, }} - .ToStringWithArgs() + + .ToString() + "\nNote:\n" "Issuing the walletpassphrase command while the wallet is already " "unlocked will set a new unlock\n" @@ -2451,7 +2451,7 @@ {"newpassphrase", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The new passphrase"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("walletpassphrasechange", "\"old one\" \"new one\"") + @@ -2577,7 +2577,7 @@ "The pass phrase to encrypt the wallet with. It must be " "at least 1 character, but should be long."}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" "\nEncrypt your wallet\n" + HelpExampleCli("encryptwallet", "\"my pass phrase\"") + @@ -2682,7 +2682,7 @@ }, }, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "true|false (boolean) Whether the command was successful or " "not\n" @@ -2883,7 +2883,7 @@ /* default_val */ "", "The transaction fee in " + CURRENCY_UNIT + "/kB"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult\n" "true|false (boolean) Returns true if successful\n" "\nExamples:\n" + @@ -3100,7 +3100,7 @@ /* default_val */ "", "The wallet directory or .dat file."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"name\" : , (string) The wallet name if " @@ -3176,7 +3176,7 @@ "Create a blank wallet. A blank wallet has no keys " "or HD seed. One can be set using sethdseed.\n"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"name\" : , (string) The wallet name if " @@ -3247,7 +3247,7 @@ {"wallet_name", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The name of the wallet to unload."}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("unloadwallet", "wallet_name") + HelpExampleRpc("unloadwallet", "wallet_name")); } @@ -3392,7 +3392,7 @@ }, "query_options"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult\n" "[ (array of json object)\n" " {\n" @@ -3770,7 +3770,7 @@ }, "options"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"hex\": \"value\", (string) The resulting raw " @@ -3880,7 +3880,7 @@ " \"NONE|FORKID|ANYONECANPAY\"\n" " \"SINGLE|FORKID|ANYONECANPAY\""}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"hex\" : \"value\", (string) The hex-encoded " @@ -3949,7 +3949,7 @@ /* default_val */ "", "How many iterations to try (default = 1000000)."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[ blockhashes ] (array) hashes of blocks generated\n" "\nExamples:\n" @@ -4003,7 +4003,7 @@ /* default_val */ "", "the last block height that should be scanned"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"start_height\" (numeric) The block height where the " @@ -4214,7 +4214,7 @@ /* default_val */ "", "The bitcoin address to get the information of."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"address\" : \"address\", (string) The bitcoin address " @@ -4367,7 +4367,7 @@ {"label", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The label."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{ (json object with addresses as keys)\n" " \"address\": { (json object with information about address)\n" @@ -4422,7 +4422,7 @@ "('send','receive'). An empty string is the same " "as not providing this argument."}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "[ (json array of string)\n" " \"label\", (string) Label name\n" @@ -4503,7 +4503,7 @@ "retrieved using the dumpwallet command. It is the " "private key marked hdseed=1"}, }} - .ToStringWithArgs() + + .ToString() + "\nExamples:\n" + HelpExampleCli("sethdseed", "") + HelpExampleCli("sethdseed", "false") + HelpExampleCli("sethdseed", "true \"wifkey\"") + @@ -4605,7 +4605,7 @@ "If true, includes the BIP 32 derivation paths for public " "keys if we know them"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"psbt\" : \"value\", (string) The base64-encoded " @@ -4799,7 +4799,7 @@ "If true, includes the BIP 32 derivation paths for public " "keys if we know them"}, }} - .ToStringWithArgs() + + .ToString() + "\nResult:\n" "{\n" " \"psbt\": \"value\", (string) The resulting raw "