diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index b8592153a60bfc..32eb6b6f19c8dc 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -288,7 +288,7 @@ static RPCHelpMan waitfornewblock() "\nWaits for a specific new block and returns useful info about it.\n" "\nReturns the current block on timeout or exit.\n", { - {"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."}, + {"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in milliseconds to wait for a response. 0 indicates no timeout."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -331,7 +331,7 @@ static RPCHelpMan waitforblock() "\nReturns the current block on timeout or exit.\n", { {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Block hash to wait for."}, - {"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."}, + {"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in milliseconds to wait for a response. 0 indicates no timeout."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -378,7 +378,7 @@ static RPCHelpMan waitforblockheight() "\nReturns the current block on timeout or exit.\n", { {"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "Block height to wait for."}, - {"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."}, + {"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in milliseconds to wait for a response. 0 indicates no timeout."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -571,6 +571,7 @@ UniValue MempoolToJSON(const CTxMemPool& pool, llmq::CInstantSendManager* isman, return o; } } + } static RPCHelpMan getrawmempool() @@ -579,8 +580,8 @@ static RPCHelpMan getrawmempool() "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n" "\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n", { - {"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"}, - {"mempool_sequence", RPCArg::Type::BOOL, /* default */ "false", "If verbose=false, returns a json object with transaction list and mempool sequence number attached."}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"}, + {"mempool_sequence", RPCArg::Type::BOOL, RPCArg::Default{false}, "If verbose=false, returns a json object with transaction list and mempool sequence number attached."}, }, { RPCResult{"for verbose = false", @@ -632,7 +633,7 @@ static RPCHelpMan getmempoolancestors() "\nIf txid is in the mempool, returns all in-mempool ancestors.\n", { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"}, - {"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"}, }, { RPCResult{"for verbose = false", @@ -699,7 +700,7 @@ static RPCHelpMan getmempooldescendants() "\nIf txid is in the mempool, returns all in-mempool descendants.\n", { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"}, - {"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"}, }, { RPCResult{"for verbose = false", @@ -922,7 +923,7 @@ static RPCHelpMan getblockheader() "If verbose is true, returns an Object with information about blockheader .\n", { {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, - {"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for a json object, false for the hex-encoded data"}, }, { RPCResult{"for verbose = true", @@ -996,8 +997,8 @@ static RPCHelpMan getblockheaders() "If verbose is true, each item is an Object with information about a single blockheader.\n", { {"blockhash", 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"}, + {"count", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%s", MAX_HEADERS_RESULTS)}, ""}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for a json object, false for the hex-encoded data"}, }, { RPCResult{"for verbose = true", @@ -1134,7 +1135,7 @@ static RPCHelpMan getmerkleblocks() { {"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"}, {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, - {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, + {"count", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%s", MAX_HEADERS_RESULTS), ""}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -1210,7 +1211,7 @@ static RPCHelpMan getblock() "If verbosity is 2, returns an Object with information about block and information about each transaction. \n", { {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, - {"verbosity|verbose", RPCArg::Type::NUM, /* default */ "1", "0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data"}, + {"verbosity|verbose", RPCArg::Type::NUM, RPCArg::Default{1}, "0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data"}, }, { RPCResult{"for verbosity = 0", @@ -1387,9 +1388,9 @@ static RPCHelpMan gettxoutsetinfo() "\nReturns statistics about the unspent transaction output set.\n" "Note this call may take some time if you are not using coinstatsindex.\n", { - {"hash_type", RPCArg::Type::STR, /* default */ "hash_serialized_2", "Which UTXO set hash should be calculated. Options: 'hash_serialized_2' (the legacy algorithm), 'muhash', 'none'."}, + {"hash_type", RPCArg::Type::STR, RPCArg::Default{"hash_serialized_2"}, "Which UTXO set hash should be calculated. Options: 'hash_serialized_2' (the legacy algorithm), 'muhash', 'none'."}, {"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The block hash or height of the target height (only available with coinstatsindex).", "", {"", "string or numeric"}}, - {"use_index", RPCArg::Type::BOOL, /* default */ "true", "Use coinstatsindex, if available."}, + {"use_index", RPCArg::Type::BOOL, RPCArg::Default{true}, "Use coinstatsindex, if available."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -1419,7 +1420,7 @@ static RPCHelpMan gettxoutsetinfo() }} }}, }}, - RPCExamples{ + RPCExamples{ HelpExampleCli("gettxoutsetinfo", "") + HelpExampleCli("gettxoutsetinfo", R"("none")") + HelpExampleCli("gettxoutsetinfo", R"("none" 1000)") + @@ -1531,7 +1532,7 @@ static RPCHelpMan gettxout() { {"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"}, {"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"}, - {"include_mempool", RPCArg::Type::BOOL, /* default */ "true", "Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."}, + {"include_mempool", RPCArg::Type::BOOL, RPCArg::Default{true}, "Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."}, }, { RPCResult{"If the UTXO was not found", RPCResult::Type::NONE, "", ""}, @@ -1618,9 +1619,9 @@ static RPCHelpMan verifychain() return RPCHelpMan{"verifychain", "\nVerifies blockchain database.\n", { - {"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL), + {"checklevel", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL), strprintf("How thorough the block verification is:\n - %s", Join(CHECKLEVEL_DOC, "\n- "))}, - {"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."}, + {"nblocks", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."}, }, RPCResult{ RPCResult::Type::BOOL, "", "Verified or not"}, @@ -2170,8 +2171,8 @@ static RPCHelpMan getchaintxstats() return RPCHelpMan{"getchaintxstats", "\nCompute statistics about the total number and rate of transactions in the chain.\n", { - {"nblocks", RPCArg::Type::NUM, /* default */ "one month", "Size of the window in number of blocks"}, - {"blockhash", RPCArg::Type::STR_HEX, /* default */ "chain tip", "The hash of the block that ends the window."}, + {"nblocks", RPCArg::Type::NUM, RPCArg::DefaultHint{"one month"}, "Size of the window in number of blocks"}, + {"blockhash", RPCArg::Type::STR_HEX, RPCArg::DefaultHint{"chain tip"}, "The hash of the block that ends the window."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -2320,7 +2321,7 @@ static RPCHelpMan getblockstats() "It won't work for some heights with pruning.\n", { {"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block hash or height of the target block", "", {"", "string or numeric"}}, - {"stats", RPCArg::Type::ARR, /* default */ "all values", "Values to plot (see result below)", + {"stats", RPCArg::Type::ARR, RPCArg::DefaultHint{"all values"}, "Values to plot (see result below)", { {"height", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Selected statistic"}, {"time", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Selected statistic"}, @@ -2540,8 +2541,8 @@ static RPCHelpMan getspecialtxes() {"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"}, + {"skip", RPCArg::Type::NUM, RPCArg::Default{0}, "The number of transactions to skip"}, + {"verbosity", RPCArg::Type::NUM, RPCArg::Default{0}, "0 for hashes, 1 for hex-encoded data, and 2 for json object"}, }, { RPCResult{"for verbosity = 0", @@ -2755,7 +2756,7 @@ static RPCHelpMan scantxoutset() {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with output descriptor and metadata", { {"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"}, - {"range", RPCArg::Type::RANGE, /* default */ "1000", "The range of HD chain indexes to explore (either end or [begin,end])"}, + {"range", RPCArg::Type::RANGE, RPCArg::Default{1000}, "The range of HD chain indexes to explore (either end or [begin,end])"}, }, }, }, @@ -2901,7 +2902,7 @@ static RPCHelpMan getblockfilter() "\nRetrieve a BIP 157 content filter for a particular block.\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"}, + {"filtertype", RPCArg::Type::STR, RPCArg::Default{"basic"}, "The type name of the filter"}, }, RPCResult{ RPCResult::Type::OBJ, "", "", diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 50956048dab137..9e956ce9122970 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -102,8 +102,8 @@ static RPCHelpMan getnetworkhashps() "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n" "Pass in [height] to estimate the network speed at the time when a certain block was found.\n", { - {"nblocks", RPCArg::Type::NUM, /* default */ "120", "The number of blocks, or -1 for blocks since last difficulty change."}, - {"height", RPCArg::Type::NUM, /* default */ "-1", "To estimate at the time of the given height."}, + {"nblocks", RPCArg::Type::NUM, RPCArg::Default{120}, "The number of blocks, or -1 for blocks since last difficulty change."}, + {"height", RPCArg::Type::NUM, RPCArg::Default{-1}, "To estimate at the time of the given height."}, }, RPCResult{ RPCResult::Type::NUM, "", "Hashes per second estimated"}, @@ -230,7 +230,7 @@ static RPCHelpMan generatetodescriptor() { {"num_blocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated immediately."}, {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor to send the newly generated coins to."}, - {"maxtries", RPCArg::Type::NUM, /* default */ ToString(DEFAULT_MAX_TRIES), "How many iterations to try."}, + {"maxtries", RPCArg::Type::NUM, RPCArg::Default{DEFAULT_MAX_TRIES}, "How many iterations to try."}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -267,7 +267,7 @@ static RPCHelpMan generatetoaddress() { {"nblocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated immediately."}, {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address to send the newly generated coins to."}, - {"maxtries", RPCArg::Type::NUM, /* default */ ToString(DEFAULT_MAX_TRIES), "How many iterations to try."}, + {"maxtries", RPCArg::Type::NUM, RPCArg::Default{DEFAULT_MAX_TRIES}, "How many iterations to try."}, }, RPCResult{ RPCResult::Type::ARR, "", "hashes of blocks generated", @@ -563,7 +563,7 @@ static RPCHelpMan getblocktemplate() " https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n" " https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n", { - {"template_request", RPCArg::Type::OBJ, /* default_val */ "", "Format of the template", + {"template_request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "Format of the template", { {"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"}, {"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings", @@ -1020,7 +1020,7 @@ static RPCHelpMan submitblock() "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n", { {"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded block data to submit"}, - {"dummy", RPCArg::Type::STR, /* default */ "ignored", "dummy value, for compatibility with BIP22. This value is ignored."}, + {"dummy", RPCArg::Type::STR, RPCArg::DefaultHint{"ignored"}, "dummy value, for compatibility with BIP22. This value is ignored."}, }, { RPCResult{"If the block was accepted", RPCResult::Type::NONE, "", ""}, @@ -1120,7 +1120,7 @@ static RPCHelpMan estimatesmartfee() "for which the estimate is valid.\n", { {"conf_target", RPCArg::Type::NUM, RPCArg::Optional::NO, "Confirmation target in blocks (1 - 1008)"}, - {"estimate_mode", RPCArg::Type::STR, /* default */ "conservative", "The fee estimate mode.\n" + {"estimate_mode", RPCArg::Type::STR, RPCArg::Default{"conservative"}, "The fee estimate mode.\n" " Whether to return a more conservative estimate which also satisfies\n" " a longer history. A conservative estimate potentially returns a\n" " higher feerate and is more likely to be sufficient for the desired\n" @@ -1195,7 +1195,7 @@ static RPCHelpMan estimaterawfee() "confirmation within conf_target blocks if possible.\n", { {"conf_target", RPCArg::Type::NUM, RPCArg::Optional::NO, "Confirmation target in blocks (1 - 1008)"}, - {"threshold", RPCArg::Type::NUM, /* default */ "0.95", "The proportion of transactions in a given feerate range that must have been\n" + {"threshold", RPCArg::Type::NUM, RPCArg::Default{0.95}, "The proportion of transactions in a given feerate range that must have been\n" " confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n" " lower buckets."}, }, diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 6872f41115a19b..c052ee0d73f5de 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -709,9 +709,9 @@ static RPCHelpMan getaddressmempool() return RPCHelpMan{"getaddressmempool", "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* default */ "", "", + {"addresses", RPCArg::Type::ARR, RPCArg::DefaultHint{""}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::DefaultHint{""}, "The base58check encoded address"}, }, }, }, @@ -782,9 +782,9 @@ static RPCHelpMan getaddressutxos() return RPCHelpMan{"getaddressutxos", "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* default */ "", "", + {"addresses", RPCArg::Type::ARR, RPCArg::DefaultHint{""}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::DefaultHint{""}, "The base58check encoded address"}, }, }, }, @@ -855,9 +855,9 @@ static RPCHelpMan getaddressdeltas() return RPCHelpMan{"getaddressdeltas", "\nReturns all changes for an address (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* default */ "", "", + {"addresses", RPCArg::Type::ARR, RPCArg::DefaultHint{""}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::DefaultHint{""}, "The base58check encoded address"}, }, }, }, @@ -952,9 +952,9 @@ static RPCHelpMan getaddressbalance() return RPCHelpMan{"getaddressbalance", "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* default */ "", "", + {"addresses", RPCArg::Type::ARR, RPCArg::DefaultHint{""}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::DefaultHint{""}, "The base58check encoded address"}, }, }, }, @@ -1029,9 +1029,9 @@ static RPCHelpMan getaddresstxids() return RPCHelpMan{"getaddresstxids", "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n", { - {"addresses", RPCArg::Type::ARR, /* default */ "", "", + {"addresses", RPCArg::Type::ARR, RPCArg::DefaultHint{""}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::DefaultHint{""}, "The base58check encoded address"}, }, }, }, @@ -1116,10 +1116,10 @@ static RPCHelpMan getspentinfo() return RPCHelpMan{"getspentinfo", "\nReturns the txid and index where an output is spent.\n", { - {"request", RPCArg::Type::OBJ, /* default */ "", "", + {"request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "", { - {"txid", RPCArg::Type::STR_HEX, /* default */ "", "The hex string of the txid"}, - {"index", RPCArg::Type::NUM, /* default */ "", "The start block height"}, + {"txid", RPCArg::Type::STR_HEX, RPCArg::DefaultHint{""}, "The hex string of the txid"}, + {"index", RPCArg::Type::NUM, RPCArg::DefaultHint{""}, "The start block height"}, }, }, }, @@ -1238,7 +1238,7 @@ static RPCHelpMan getmemoryinfo() return RPCHelpMan{"getmemoryinfo", "Returns an object containing information about memory usage.\n", { - {"mode", RPCArg::Type::STR, /* default */ "\"stats\"", "determines what kind of information is returned.\n" + {"mode", RPCArg::Type::STR, RPCArg::Default{"stats"}, "determines what kind of information is returned.\n" " - \"stats\" returns general statistics about memory usage in the daemon.\n" " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+)."}, }, diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index b8bdd38939b565..e22318e55c1098 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -408,8 +408,8 @@ static RPCHelpMan disconnectnode() "\nStrictly one out of 'address' and 'nodeid' can be provided to identify the node.\n" "\nTo disconnect by nodeid, either set 'address' to the empty string, or call using the named 'nodeid' argument only.\n", { - {"address", RPCArg::Type::STR, /* default */ "fallback to nodeid", "The IP address/port of the node"}, - {"nodeid", RPCArg::Type::NUM, /* default */ "fallback to address", "The node ID (see getpeerinfo for node IDs)"}, + {"address", RPCArg::Type::STR, RPCArg::DefaultHint{"fallback to nodeid"}, "The IP address/port of the node"}, + {"nodeid", RPCArg::Type::NUM, RPCArg::DefaultHint{"fallback to address"}, "The node ID (see getpeerinfo for node IDs)"}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -454,7 +454,7 @@ static RPCHelpMan getaddednodeinfo() "\nReturns information about the given added node, or all added nodes\n" "(note that onetry addnodes are not listed here)\n", { - {"node", RPCArg::Type::STR, /* default */ "all nodes", "If provided, return information about this specific node, otherwise all nodes are returned."}, + {"node", RPCArg::Type::STR, RPCArg::DefaultHint{"all nodes"}, "If provided, return information about this specific node, otherwise all nodes are returned."}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -706,8 +706,8 @@ static RPCHelpMan setban() { {"subnet", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP)"}, {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list"}, - {"bantime", RPCArg::Type::NUM, /* default */ "0", "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, /* default */ "false", "If set, the bantime must be an absolute timestamp expressed in " + UNIX_EPOCH_TIME}, + {"bantime", RPCArg::Type::NUM, RPCArg::Default{0}, "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, RPCArg::Default{false}, "If set, the bantime must be an absolute timestamp expressed in " + UNIX_EPOCH_TIME}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -909,8 +909,8 @@ static RPCHelpMan getnodeaddresses() return RPCHelpMan{"getnodeaddresses", "\nReturn known addresses, which can potentially be used to find new nodes in the network.\n", { - {"count", RPCArg::Type::NUM, /* default */ "1", "The maximum number of addresses to return. Specify 0 to return all known addresses."}, - {"network", RPCArg::Type::STR, /* default */ "all networks", "Return only addresses of the specified network. Can be one of: " + Join(GetNetworkNames(), ", ") + "."}, + {"count", RPCArg::Type::NUM, RPCArg::Default{1}, "The maximum number of addresses to return. Specify 0 to return all known addresses."}, + {"network", RPCArg::Type::STR, RPCArg::DefaultHint{"all networks"}, "Return only addresses of the specified network. Can be one of: " + Join(GetNetworkNames(), ", ") + "."}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -970,7 +970,7 @@ static RPCHelpMan addpeeraddress() { {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address of the peer"}, {"port", RPCArg::Type::NUM, RPCArg::Optional::NO, "The port of the peer"}, - {"tried", RPCArg::Type::BOOL, /* default */ "false", "If true, attempt to add the peer to the tried addresses table"}, + {"tried", RPCArg::Type::BOOL, RPCArg::Default{false}, "If true, attempt to add the peer to the tried addresses table"}, }, RPCResult{ RPCResult::Type::OBJ, "", "", diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index fa8994c70aa865..f5dadbcfebc60a 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -131,7 +131,7 @@ static RPCHelpMan getrawtransaction() "If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n", { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"verbose", RPCArg::Type::BOOL, /* default */ "false", "If false, return a string, otherwise return a json object"}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "If false, return a string, otherwise return a json object"}, {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED_NAMED_ARG, "The block in which to look for the transaction"}, }, { @@ -290,7 +290,7 @@ static RPCHelpMan getrawtransactionmulti() { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "The transaction id"}, }}, }}, - {"verbose", RPCArg::Type::BOOL, /* default */ "false", + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "If false, return a string, otherwise return a json object"}, }, RPCResults{}, @@ -744,7 +744,7 @@ static RPCHelpMan createrawtransaction() { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - {"sequence", RPCArg::Type::NUM, /* default */ "", "The sequence number"}, + {"sequence", RPCArg::Type::NUM, RPCArg::DefaultHint{""}, "The sequence number"}, }, }, }, @@ -766,7 +766,7 @@ static RPCHelpMan createrawtransaction() }, }, }, - {"locktime", RPCArg::Type::NUM, /* default */ "0", "Raw locktime. Non-0 value also locktime-activates inputs"}, + {"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"}, }, RPCResult{ RPCResult::Type::STR_HEX, "transaction", "hex string of the transaction" @@ -1047,7 +1047,7 @@ static RPCHelpMan signrawtransactionwithkey() }, }, }, - {"sighashtype", RPCArg::Type::STR, /* default */ "ALL", "The signature hash type. Must be one of:\n" + {"sighashtype", RPCArg::Type::STR, RPCArg::Default{"ALL"}, "The signature hash type. Must be one of:\n" " \"ALL\"\n" " \"NONE\"\n" " \"SINGLE\"\n" @@ -1126,7 +1126,7 @@ RPCHelpMan sendrawtransaction() "\nRelated RPCs: createrawtransaction, signrawtransactionwithkey\n", { {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"}, - {"maxfeerate", RPCArg::Type::AMOUNT, /* default */ FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK()), + {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())}, "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kB.\nSet to 0 to accept any fee rate.\n"}, {"instantsend", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Deprecated and ignored"}, @@ -1196,7 +1196,7 @@ static RPCHelpMan testmempoolaccept() {"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""}, }, }, - {"maxfeerate", RPCArg::Type::AMOUNT, /* default */ FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK()), + {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())}, "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kB\n"}, }, RPCResult{ @@ -1631,7 +1631,7 @@ static RPCHelpMan finalizepsbt() "Implements the Finalizer and Extractor roles.\n", { {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"}, - {"extract", RPCArg::Type::BOOL, /* default */ "true", "If true and the transaction is complete,\n" + {"extract", RPCArg::Type::BOOL, RPCArg::Default{true}, "If true and the transaction is complete,\n" " extract and return the complete transaction in normal network serialization instead of the PSBT."}, }, RPCResult{ @@ -1693,7 +1693,7 @@ static RPCHelpMan createpsbt() { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - {"sequence", RPCArg::Type::NUM, /* default */ "depends on the value of 'locktime' argument", "The sequence number"}, + {"sequence", RPCArg::Type::NUM, RPCArg::DefaultHint{"depends on the value of 'locktime' argument"}, "The sequence number"}, }, }, }, @@ -1715,7 +1715,7 @@ static RPCHelpMan createpsbt() }, }, }, - {"locktime", RPCArg::Type::NUM, /* default */ "0", "Raw locktime. Non-0 value also locktime-activates inputs"}, + {"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"}, }, RPCResult{ RPCResult::Type::STR, "", "The resulting raw transaction (base64-encoded string)" @@ -1761,7 +1761,7 @@ static RPCHelpMan converttopsbt() "createpsbt and walletcreatefundedpsbt should be used for new applications.\n", { {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of a raw transaction"}, - {"permitsigdata", RPCArg::Type::BOOL, /* default */ "false", "If true, any signatures in the input will be discarded and conversion\n" + {"permitsigdata", RPCArg::Type::BOOL, RPCArg::Default{false}, "If true, any signatures in the input will be discarded and conversion\n" " will continue. If false, RPC will fail if any signatures are present."}, }, RPCResult{ diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 7af6478c0f7257..8b101018d43208 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -168,8 +168,8 @@ static RPCHelpMan help() return RPCHelpMan{"help", "\nList all commands, or get help for a specified command.\n", { - {"command", RPCArg::Type::STR, /* default */ "all commands", "The command to get help on"}, - {"subcommand", RPCArg::Type::STR, /* default */ "all subcommands", "The subcommand to get help on."}, + {"command", RPCArg::Type::STR, RPCArg::DefaultHint{"all commands"}, "The command to get help on"}, + {"subcommand", RPCArg::Type::STR, RPCArg::DefaultHint{"all subcommands"}, "The subcommand to get help on."}, }, { RPCResult{RPCResult::Type::STR, "", "The help text"}, diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 3b02da632f693f..f6d530688dbb2a 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -469,6 +469,33 @@ RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector(arg.m_fallback).getType()) { + case UniValue::VOBJ: + CHECK_NONFATAL(type == RPCArg::Type::OBJ); + break; + case UniValue::VARR: + CHECK_NONFATAL(type == RPCArg::Type::ARR); + break; + case UniValue::VSTR: + CHECK_NONFATAL(type == RPCArg::Type::STR || type == RPCArg::Type::STR_HEX || type == RPCArg::Type::AMOUNT); + break; + case UniValue::VNUM: + CHECK_NONFATAL(type == RPCArg::Type::NUM || type == RPCArg::Type::AMOUNT || type == RPCArg::Type::RANGE); + break; + case UniValue::VBOOL: + CHECK_NONFATAL(type == RPCArg::Type::BOOL); + break; + case UniValue::VNULL: + // Null values are accepted in all arguments + break; + default: + CHECK_NONFATAL(false); + break; + } + } } } @@ -614,7 +641,7 @@ std::string RPCArg::GetName() const bool RPCArg::IsOptional() const { - if (m_fallback.index() == 1) { + if (m_fallback.index() != 0) { return true; } else { return RPCArg::Optional::NO != std::get(m_fallback); @@ -662,7 +689,9 @@ std::string RPCArg::ToDescriptionString() const } // no default case, so the compiler can warn about missing cases } if (m_fallback.index() == 1) { - ret += ", optional, default=" + std::get(m_fallback); + ret += ", optional, default=" + std::get(m_fallback); + } else if (m_fallback.index() == 2) { + ret += ", optional, default=" + std::get(m_fallback).write(); } else { switch (std::get(m_fallback)) { case RPCArg::Optional::OMITTED: { diff --git a/src/rpc/util.h b/src/rpc/util.h index 189551cd037937..b97b4ca436c317 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -148,7 +148,9 @@ struct RPCArg { */ OMITTED, }; - using Fallback = std::variant; + using DefaultHint = std::string; + using Default = UniValue; + using Fallback = std::variant; const std::string m_names; //!< The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments) const Type m_type; const bool m_hidden; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 16ac2596ab11d4..688ab53aae5ace 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -80,8 +80,8 @@ RPCHelpMan importprivkey() "may report that the imported key exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n", { {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key (see dumpprivkey)"}, - {"label", RPCArg::Type::STR, /* default */ "current label if address exists, otherwise \"\"", "An optional label"}, - {"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"}, + {"label", RPCArg::Type::STR, RPCArg::DefaultHint{"current label if address exists, otherwise \"\""}, "An optional label"}, + {"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Rescan the wallet for transactions"}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -200,9 +200,9 @@ RPCHelpMan importaddress() "as change, and not show up in many RPCs.\n", { {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The Dash address (or hex-encoded script)"}, - {"label", RPCArg::Type::STR, /* default */ "\"\"", "An optional label"}, - {"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"}, - {"p2sh", RPCArg::Type::BOOL, /* default */ "false", "Add the P2SH version of the script as well"}, + {"label", RPCArg::Type::STR, RPCArg::Default{""}, "An optional label"}, + {"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Rescan the wallet for transactions"}, + {"p2sh", RPCArg::Type::BOOL, RPCArg::Default{false}, "Add the P2SH version of the script as well"}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -393,8 +393,8 @@ RPCHelpMan importpubkey() "may report that the imported pubkey exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n", { {"pubkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The hex-encoded public key"}, - {"label", RPCArg::Type::STR, /* default */ "\"\"", "An optional label"}, - {"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"}, + {"label", RPCArg::Type::STR, RPCArg::Default{""}, "An optional label"}, + {"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Rescan the wallet for transactions"}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -634,7 +634,7 @@ RPCHelpMan importelectrumwallet() "\nImports keys from an Electrum wallet export file (.csv or .json)\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"}, + {"index", RPCArg::Type::NUM, RPCArg::Default{0}, "Rescan the wallet for transactions starting from this block index"}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -1462,7 +1462,7 @@ RPCHelpMan importmulti() { {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", { - {"desc", RPCArg::Type::STR, /* default */ "", "Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys" + {"desc", RPCArg::Type::STR, RPCArg::DefaultHint{""}, "Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys" }, {"scriptPubKey", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor", /* oneline_description */ "", {"\"