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", {}} - .ToString() + + .ToStringWithArgs() + "\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", {}} - .ToString() + + .ToStringWithArgs() + "\nExamples:\n" + HelpExampleCli("ping", "") + HelpExampleRpc("ping", "")); } @@ -86,7 +86,7 @@ "\nReturns data about each connected network node as a " "json array of objects.\n", {}} - .ToString() + + .ToStringWithArgs() + "\nResult:\n" "[\n" " {\n" @@ -264,16 +264,16 @@ "full nodes as other outbound peers are (though such peers " "will not be synced from).\n", { - {"node", RPCArg::Type::STR, false}, - {"command", RPCArg::Type::STR, false}, + {"node", RPCArg::Type::STR, /* opt */ false, + /* default_val */ "", + "The node (see getpeerinfo for nodes)"}, + {"command", RPCArg::Type::STR, /* opt */ false, + /* default_val */ "", + "'add' to add a node to the list, 'remove' to remove a " + "node from the list, 'onetry' to try a connection to the " + "node once"}, }} - .ToString() + - "\nArguments:\n" - "1. \"node\" (string, required) The node (see getpeerinfo for " - "nodes)\n" - "2. \"command\" (string, required) 'add' to add a node to the " - "list, 'remove' to remove a node from the list, 'onetry' to try a " - "connection to the node once\n" + .ToStringWithArgs() + "\nExamples:\n" + HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") + HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")); @@ -319,15 +319,13 @@ "\nTo disconnect by nodeid, either set 'address' to the empty " "string, or call using the named 'nodeid' argument only.\n", { - {"address", RPCArg::Type::STR, true}, - {"nodeid", RPCArg::Type::NUM, true}, + {"address", RPCArg::Type::STR, /* opt */ true, + /* default_val */ "", "The IP address/port of the node"}, + {"nodeid", RPCArg::Type::NUM, /* opt */ true, + /* default_val */ "", + "The node ID (see getpeerinfo for node IDs)"}, }} - .ToString() + - "\nArguments:\n" - "1. \"address\" (string, optional) The IP address/port of the " - "node\n" - "2. \"nodeid\" (number, optional) The node ID (see " - "getpeerinfo for node IDs)\n" + .ToStringWithArgs() + "\nExamples:\n" + HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") + HelpExampleCli("disconnectnode", "\"\" 1") + @@ -377,12 +375,12 @@ "all added nodes\n" "(note that onetry addnodes are not listed here)\n", { - {"node", RPCArg::Type::STR, true}, + {"node", RPCArg::Type::STR, /* opt */ true, + /* default_val */ "", + "If provided, return information about this " + "specific node, otherwise all nodes are returned."}, }} - .ToString() + - "\nArguments:\n" - "1. \"node\" (string, optional) If provided, return information " - "about this specific node, otherwise all nodes are returned.\n" + .ToStringWithArgs() + "\nResult:\n" "[\n" " {\n" @@ -458,7 +456,7 @@ "bytes in, bytes out,\n" "and current time.\n", {}} - .ToString() + + .ToStringWithArgs() + "\nResult:\n" "{\n" " \"totalbytesrecv\": n, (numeric) Total bytes received\n" @@ -541,7 +539,7 @@ "Returns an object containing various state info " "regarding P2P networking.\n", {}} - .ToString() + + .ToStringWithArgs() + "\nResult:\n" "{\n" " \"version\": xxxxx, (numeric) the server " @@ -650,29 +648,31 @@ if (request.fHelp || request.params.size() < 2 || (strCommand != "add" && strCommand != "remove")) { throw std::runtime_error( - RPCHelpMan{"setban", - "\nAttempts to add or remove an IP/Subnet from the " - "banned list.\n", - { - {"subnet", RPCArg::Type::STR, false}, - {"command", RPCArg::Type::STR, false}, - {"bantime", RPCArg::Type::NUM, true}, - {"absolute", RPCArg::Type::BOOL, true}, - }} - .ToString() + - "\nArguments:\n" - "1. \"subnet\" (string, required) The IP/Subnet (see " - "getpeerinfo for nodes IP) with an optional netmask (default is " - "/32 " - "= single IP)\n" - "2. \"command\" (string, required) 'add' to add an IP/Subnet " - "to the list, 'remove' to remove an IP/Subnet from the list\n" - "3. \"bantime\" (numeric, optional) time in seconds how long " - "(or until when if [absolute] is set) the IP is banned (0 or empty " - "means using the default time of 24h which can also be overwritten " - "by the -bantime startup argument)\n" - "4. \"absolute\" (boolean, optional) If set, the bantime must " - "be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n" + RPCHelpMan{ + "setban", + "\nAttempts to add or remove an IP/Subnet from the " + "banned list.\n", + { + {"subnet", RPCArg::Type::STR, /* opt */ false, + /* default_val */ "", + "The IP/Subnet (see getpeerinfo for nodes IP) with an " + "optional netmask (default is /32 = single IP)"}, + {"command", RPCArg::Type::STR, /* opt */ false, + /* default_val */ "", + "'add' to add an IP/Subnet to the list, 'remove' to " + "remove an IP/Subnet from the list"}, + {"bantime", RPCArg::Type::NUM, /* opt */ true, + /* default_val */ "", + "time in seconds how long (or until when if [absolute] is " + "set) the IP is banned (0 or empty means using the " + "default time of 24h which can also be overwritten by the " + "-bantime startup argument)"}, + {"absolute", RPCArg::Type::BOOL, /* opt */ true, + /* default_val */ "", + "If set, the bantime must be an absolute timestamp in " + "seconds since epoch (Jan 1 1970 GMT)"}, + }} + .ToStringWithArgs() + "\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", {}} - .ToString() + + .ToStringWithArgs() + "\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", {}} - .ToString() + + .ToStringWithArgs() + "\nExamples:\n" + HelpExampleCli("clearbanned", "") + HelpExampleRpc("clearbanned", "")); } @@ -800,16 +800,14 @@ static UniValue setnetworkactive(const Config &config, const JSONRPCRequest &request) { if (request.fHelp || request.params.size() != 1) { - throw std::runtime_error( - RPCHelpMan{"setnetworkactive", - "\nDisable/enable all p2p network activity.\n", - { - {"state", RPCArg::Type::BOOL, false}, - }} - .ToString() + - "\nArguments:\n" - "1. \"state\" (boolean, required) true to " - "enable networking, false to disable\n"); + throw std::runtime_error(RPCHelpMan{ + "setnetworkactive", + "\nDisable/enable all p2p network activity.\n", + { + {"state", RPCArg::Type::BOOL, /* opt */ false, + /* default_val */ "", + "true to enable networking, false to disable"}, + }}.ToStringWithArgs()); } if (!g_connman) { @@ -831,15 +829,15 @@ "\nReturn known addresses which can potentially be used " "to find new nodes in the network\n", { - {"count", RPCArg::Type::NUM, true}, + {"count", RPCArg::Type::NUM, /* opt */ true, + /* default_val */ "1", + "How many addresses to return. Limited to the " + "smaller of " + + std::to_string(ADDRMAN_GETADDR_MAX) + " or " + + std::to_string(ADDRMAN_GETADDR_MAX_PCT) + + "% of all known addresses."}, }} - .ToString() + - "\nArguments:\n" - "1. \"count\" (numeric, optional) How many addresses to return. " - "Limited to the smaller of " + - std::to_string(ADDRMAN_GETADDR_MAX) + " or " + - std::to_string(ADDRMAN_GETADDR_MAX_PCT) + - "% of all known addresses. (default = 1)\n" + .ToStringWithArgs() + "\nResult:\n" "[\n" " {\n"