diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c62b0e8e6e..6bf41d7ba8 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -289,7 +289,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, "", "", @@ -332,7 +332,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, "", "", @@ -379,7 +379,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, "", "", @@ -580,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", @@ -633,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", @@ -700,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", @@ -923,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", @@ -997,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_UNCOMPRESSED_RESULT), ""}, - {"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"}, + {"count", RPCArg::Type::NUM, RPCArg::Default{int{MAX_HEADERS_UNCOMPRESSED_RESULT}}, ""}, + {"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for a json object, false for the hex-encoded data"}, }, { RPCResult{"for verbose = true", @@ -1135,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_UNCOMPRESSED_RESULT), ""}, + {"count", RPCArg::Type::NUM, RPCArg::Default{int{MAX_HEADERS_UNCOMPRESSED_RESULT}}, ""}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -1211,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", @@ -1388,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_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."}, + {"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_NAMED_ARG, "The block hash or height of the target height (only available with coinstatsindex).", "", {"", "string or numeric"}}, + {"use_index", RPCArg::Type::BOOL, RPCArg::Default{true}, "Use coinstatsindex, if available."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -1532,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, "", ""}, @@ -1619,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", MakeUnorderedList(CHECKLEVEL_DOC))}, - {"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"}, @@ -1872,8 +1872,8 @@ static RPCHelpMan getchaintips() "Return information about all known tips in the block tree," " including the main chain as well as orphaned branches.\n", { - {"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"}, + {"count", RPCArg::Type::NUM, RPCArg::Default{INT_MAX}, "only show this much of latest tips"}, + {"branchlen", RPCArg::Type::NUM, RPCArg::Default{-1}, "only show tips that have equal or greater length of branch"}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -1932,14 +1932,8 @@ static RPCHelpMan getchaintips() // Always report the currently active tip. setTips.insert(active_chain.Tip()); - int nBranchMin = -1; - int nCountMax = INT_MAX; - - if(!request.params[0].isNull()) - nCountMax = request.params[0].get_int(); - - if(!request.params[1].isNull()) - nBranchMin = request.params[1].get_int(); + int nCountMax{request.params[0].isNull() ? INT_MAX : request.params[0].get_int()}; + const int nBranchMin{request.params[1].isNull() ? -1: request.params[1].get_int()}; /* Construct the output array. */ UniValue res(UniValue::VARR); @@ -2174,8 +2168,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, "", "", @@ -2324,7 +2318,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"}, @@ -2542,10 +2536,10 @@ static RPCHelpMan getspecialtxes() "If verbosity is 2, returns an Object with information for each transaction.\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"}, + {"type", RPCArg::Type::NUM, RPCArg::Default{-1}, "Filter special txes by type, -1 means all types"}, + {"count", RPCArg::Type::NUM, RPCArg::Default{10}, "The number of transactions to return"}, + {"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", @@ -2767,7 +2761,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])"}, }, }, }, @@ -2913,7 +2907,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/coinjoin.cpp b/src/rpc/coinjoin.cpp index 68210881a7..77dc18949c 100644 --- a/src/rpc/coinjoin.cpp +++ b/src/rpc/coinjoin.cpp @@ -207,7 +207,7 @@ static RPCHelpMan coinjoinsalt_generate() "\nGenerate new CoinJoin salt and store it in the wallet database\n" "Cannot generate new salt if CoinJoin mixing is in process or wallet has private keys disabled.\n", { - {"overwrite", RPCArg::Type::BOOL, /* default */ "false", "Generate new salt even if there is an existing salt and/or there is CoinJoin balance"}, + {"overwrite", RPCArg::Type::BOOL, RPCArg::Default{false}, "Generate new salt even if there is an existing salt and/or there is CoinJoin balance"}, }, RPCResult{ RPCResult::Type::BOOL, "", "Status of CoinJoin salt generation and commitment" @@ -309,7 +309,7 @@ static RPCHelpMan coinjoinsalt_set() "Will overwrite existing salt. The presence of a CoinJoin balance will cause the wallet to rescan.\n", { {"salt", RPCArg::Type::STR, RPCArg::Optional::NO, "Desired CoinJoin salt value for the wallet"}, - {"overwrite", RPCArg::Type::BOOL, /* default */ "false", "Overwrite salt even if CoinJoin balance present"}, + {"overwrite", RPCArg::Type::BOOL, RPCArg::Default{false}, "Overwrite salt even if CoinJoin balance present"}, }, RPCResult{ RPCResult::Type::BOOL, "", "Status of CoinJoin salt change request" diff --git a/src/rpc/evo.cpp b/src/rpc/evo.cpp index 32661616ef..30fdab04b7 100644 --- a/src/rpc/evo.cpp +++ b/src/rpc/evo.cpp @@ -59,13 +59,13 @@ static RPCArg GetRpcArg(const std::string& strParamName) "The collateral transaction output index."} }, {"feeSourceAddress", - {"feeSourceAddress", RPCArg::Type::STR, /* default */ "", + {"feeSourceAddress", RPCArg::Type::STR, RPCArg::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, /* default */ "", + {"fundAddress", RPCArg::Type::STR, RPCArg::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."} @@ -85,7 +85,7 @@ static RPCArg GetRpcArg(const std::string& strParamName) "registered operator public key."} }, {"operatorPayoutAddress", - {"operatorPayoutAddress", RPCArg::Type::STR, /* default */ "", + {"operatorPayoutAddress", RPCArg::Type::STR, RPCArg::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."} @@ -137,11 +137,11 @@ static RPCArg GetRpcArg(const std::string& strParamName) "The hash of the initial ProRegTx."} }, {"reason", - {"reason", RPCArg::Type::NUM, /* default */ "", + {"reason", RPCArg::Type::NUM, RPCArg::DefaultHint{"Reason is not specified"}, "The reason for masternode service revocation."} }, {"submit", - {"submit", RPCArg::Type::BOOL, /* default */ "true", + {"submit", RPCArg::Type::BOOL, RPCArg::Default{true}, "If true, the resulting transaction is sent to the network."} }, {"votingAddress_register", @@ -1349,7 +1349,7 @@ static RPCHelpMan protx_list() return RPCHelpMan{"protx list", "\nLists all ProTxs in your wallet or on-chain, depending on the given type.\n", { - {"type", RPCArg::Type::STR, /* default */ "registered", + {"type", RPCArg::Type::STR, RPCArg::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" @@ -1360,8 +1360,8 @@ static RPCHelpMan protx_list() " 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", ""}, + {"detailed", RPCArg::Type::BOOL, RPCArg::Default{false}, "If not specified, only the hashes of the ProTx will be returned."}, + {"height", RPCArg::Type::NUM, RPCArg::DefaultHint{"current chain-tip"}, ""}, }, RPCResults{}, RPCExamples{""}, @@ -1470,7 +1470,7 @@ static RPCHelpMan protx_info() "\nReturns detailed information about a deterministic masternode.\n", { GetRpcArg("proTxHash"), - {"blockHash", RPCArg::Type::STR_HEX, /* default*/ "(chain tip)", "The hash of the block to get deterministic masternode state at"}, + {"blockHash", RPCArg::Type::STR_HEX, RPCArg::DefaultHint{"(chain tip)"}, "The hash of the block to get deterministic masternode state at"}, }, RPCResult{ RPCResult::Type::OBJ, "", "Details about a specific deterministic masternode", @@ -1720,7 +1720,7 @@ static RPCHelpMan bls_generate() return RPCHelpMan{"bls generate", "\nReturns a BLS secret/public key pair.\n", { - {"legacy", RPCArg::Type::BOOL, /* default */ "true until the v19 fork is activated, otherwise false", "Use legacy BLS scheme"}, + {"legacy", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true until the v19 fork is activated, otherwise false"}, "Use legacy BLS scheme"}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -1759,7 +1759,7 @@ static RPCHelpMan bls_fromsecret() "\nParses a BLS secret key and returns the secret/public key pair.\n", { {"secret", RPCArg::Type::STR, RPCArg::Optional::NO, "The BLS secret key"}, - {"legacy", RPCArg::Type::BOOL, /* default */ "true until the v19 fork is activated, otherwise false", "Use legacy BLS scheme"}, + {"legacy", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true until the v19 fork is activated, otherwise false"}, "Use legacy BLS scheme"}, }, RPCResult{ RPCResult::Type::OBJ, "", "", diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index bdee7e7740..45a7ea26c4 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -33,7 +33,7 @@ static RPCHelpMan gobject_count() return RPCHelpMan{"gobject count", "Count governance objects and votes\n", { - {"mode", RPCArg::Type::STR, /* default */ "json", "Output format: json (\"json\") or string in free form (\"all\")"}, + {"mode", RPCArg::Type::STR, RPCArg::DefaultHint{"json"}, "Output format: json (\"json\") or string in free form (\"all\")"}, }, RPCResults{}, RPCExamples{""}, @@ -133,9 +133,9 @@ static RPCHelpMan gobject_prepare() {"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."}, + {"use-IS", RPCArg::Type::BOOL, RPCArg::Default{false}, "Deprecated and ignored"}, + {"outputHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "the single output to submit the proposal fee from"}, + {"outputIndex", RPCArg::Type::NUM, RPCArg::Default{0}, "The output index."}, }, RPCResults{}, RPCExamples{""}, @@ -245,7 +245,7 @@ static RPCHelpMan gobject_list_prepared() "Returns a list of governance objects prepared by this wallet with \"gobject prepare\" sorted by their creation time.\n" + HELP_REQUIRING_PASSPHRASE, { - {"count", RPCArg::Type::NUM, /* default */ "10", "Maximum number of objects to return."}, + {"count", RPCArg::Type::NUM, RPCArg::Default{10}, "Maximum number of objects to return."}, }, RPCResults{}, RPCExamples{""}, @@ -694,8 +694,8 @@ static RPCHelpMan gobject_list_helper(const bool make_a_diff) return RPCHelpMan{command, description, { - {"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]"}, + {"signal", RPCArg::Type::STR, RPCArg::Default{"valid"}, "cached signal, possible values: [valid|funding|delete|endorsed|all]"}, + {"type", RPCArg::Type::STR, RPCArg::Default{"all"}, "object type, possible values: [proposals|triggers|all]"}, }, RPCResults{}, RPCExamples{""}, @@ -837,8 +837,8 @@ static 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, 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 present"}, + {"txid", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "masternode collateral txid"}, + {"vout", RPCArg::Type::STR, RPCArg::Default{""}, "masternode collateral output index, required if present"}, }, RPCResults{}, RPCExamples{""}, diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 4f59ee498d..88819f5dbd 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -278,8 +278,8 @@ static RPCHelpMan masternode_winners() return RPCHelpMan{"masternode winners", "Print list of masternode winners\n", { - {"count", RPCArg::Type::NUM, /* default */ "", "number of last winners to return"}, - {"filter", RPCArg::Type::STR, /* default */ "", "filter for returned winners"}, + {"count", RPCArg::Type::NUM, RPCArg::Default{10}, "number of last winners to return"}, + {"filter", RPCArg::Type::STR, RPCArg::Default{""}, "filter for returned winners"}, }, RPCResults{}, RPCExamples{""}, @@ -340,8 +340,8 @@ static RPCHelpMan masternode_payments() return RPCHelpMan{"masternode payments", "\nReturns an array of deterministic masternodes and their payments for the specified block\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."}, + {"blockhash", RPCArg::Type::STR_HEX, RPCArg::DefaultHint{"tip"}, "The hash of the starting block"}, + {"count", RPCArg::Type::NUM, RPCArg::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 { RPCResult::Type::ARR, "", "Blocks", @@ -531,8 +531,8 @@ static RPCHelpMan masternodelist_helper(bool is_composite) " (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"}, + {"mode", RPCArg::Type::STR, RPCArg::DefaultHint{"json"}, "The mode to run list in"}, + {"filter", RPCArg::Type::STR, RPCArg::Default{""}, "Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available"}, }, RPCResults{}, RPCExamples{""}, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 261410a36e..af51ecc9f8 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", @@ -571,7 +571,7 @@ static RPCHelpMan getblocktemplate() {"str", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "client side supported feature, 'longpoll', 'coinbasevalue', 'proposal', 'serverlist', 'workid'"}, }, }, - {"rules", RPCArg::Type::ARR, /* default_val */ "", "A list of strings", + {"rules", RPCArg::Type::ARR, RPCArg::Default{UniValue::VARR}, "A list of strings", { {"str", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "client side supported softfork deployment"}, }, @@ -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" @@ -1196,7 +1196,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 4670387766..0250036d04 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -716,9 +716,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::Default{UniValue::VARR}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::Default{""}, "The base58check encoded address"}, }, }, }, @@ -789,9 +789,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::Default{UniValue::VARR}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::Default{""}, "The base58check encoded address"}, }, }, }, @@ -862,9 +862,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::Default{UniValue::VARR}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::Default{""}, "The base58check encoded address"}, }, }, }, @@ -959,9 +959,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::Default{UniValue::VARR}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::Default{""}, "The base58check encoded address"}, }, }, }, @@ -1036,9 +1036,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::Default{UniValue::VARR}, "", { - {"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"}, + {"address", RPCArg::Type::STR, RPCArg::Default{""}, "The base58check encoded address"}, }, }, }, @@ -1123,10 +1123,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::Default{""}, "The hex string of the txid"}, + {"index", RPCArg::Type::NUM, RPCArg::Default{0}, "The start block height"}, }, }, }, @@ -1245,7 +1245,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 7d5418c829..cee37ff690 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -156,7 +156,7 @@ static RPCHelpMan getpeerinfo() "When a message type is not listed in this json object, the bytes sent are 0.\n" "Only known message types can appear as keys in the object."} }}, - {RPCResult::Type::OBJ, "bytesrecv_per_msg", "", + {RPCResult::Type::OBJ_DYN, "bytesrecv_per_msg", "", { {RPCResult::Type::NUM, "msg", "The total bytes received aggregated by message type\n" "When a message type is not listed in this json object, the bytes received are 0.\n" @@ -410,8 +410,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{ @@ -456,7 +456,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, "", "", @@ -708,8 +708,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{ @@ -912,8 +912,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, "", "", @@ -973,7 +973,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/quorums.cpp b/src/rpc/quorums.cpp index 763d89bbd4..ba084ba364 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -41,8 +41,8 @@ static RPCHelpMan quorum_list() return RPCHelpMan{"quorum list", "List of on-chain quorums\n", { - {"count", RPCArg::Type::NUM, /* default */ "", - "Number of quorums to list. Will list active quorums if \"count\" is not specified.\n" + {"count", RPCArg::Type::NUM, RPCArg::DefaultHint{"The active quorum count if not specified"}, + "Number of quorums to list.\n" "Can be CPU/disk heavy when the value is larger than the number of active quorums." }, }, @@ -68,7 +68,7 @@ static RPCHelpMan quorum_list() int count = -1; if (!request.params[0].isNull()) { count = ParseInt32V(request.params[0], "count"); - if (count < 0) { + if (count < -1) { throw JSONRPCError(RPC_INVALID_PARAMETER, "count can't be negative"); } } @@ -100,7 +100,7 @@ static RPCHelpMan quorum_list_extended() return RPCHelpMan{"quorum listextended", "Extended list of on-chain quorums\n", { - {"height", RPCArg::Type::NUM, /* default */ "", "The height index. Will list active quorums at tip if \"height\" is not specified."}, + {"height", RPCArg::Type::NUM, RPCArg::DefaultHint{"Tip height if not specified"}, "Active quorums at the height."}, }, RPCResult{ RPCResult::Type::OBJ, "", "", @@ -234,7 +234,7 @@ static RPCHelpMan quorum_info() { {"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."}, + {"includeSkShare", RPCArg::Type::BOOL, RPCArg::Default{false}, "Include secret key share in output."}, }, RPCResults{}, RPCExamples{""}, @@ -270,7 +270,7 @@ static RPCHelpMan quorum_dkgstatus() "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, /* default */ "0", + {"detail_level", RPCArg::Type::NUM, RPCArg::Default{0}, "Detail level of output.\n" "0=Only show counts. 1=Show member indexes. 2=Show member's ProTxHashes."}, }, @@ -373,9 +373,8 @@ static RPCHelpMan quorum_memberof() "Checks which quorums the given masternode is a member of.\n", { {"proTxHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "ProTxHash of the masternode."}, - {"scanQuorumsCount", RPCArg::Type::NUM, /* default */ "", + {"scanQuorumsCount", RPCArg::Type::NUM, RPCArg::DefaultHint{"The active quorum count for each specific quorum type is used"}, "Number of quorums to scan for.\n" - "If not specified, the active quorum count for each specific quorum type is used.\n" "Can be CPU/disk heavy when the value is larger than the number of active quorums." }, }, @@ -492,8 +491,8 @@ static RPCHelpMan quorum_sign() {"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. " + {"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "The quorum identifier."}, + {"submit", RPCArg::Type::BOOL, RPCArg::Default{true}, "Submits the signature share to the network if this is true. " "Returns an object containing the signature share if this is false."}, }, RPCResults{}, @@ -519,8 +518,8 @@ static RPCHelpMan quorum_platformsign() { {"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. " + {"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "The quorum identifier."}, + {"submit", RPCArg::Type::BOOL, RPCArg::Default{true}, "Submits the signature share to the network if this is true. " "Returns an object containing the signature share if this is false."}, }, RPCResults{}, @@ -554,10 +553,10 @@ static RPCHelpMan quorum_verify() {"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 */ "", + {"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "The quorum identifier.\n" "Set to \"\" if you want to specify signHeight instead."}, - {"signHeight", RPCArg::Type::NUM, /* default */ "", + {"signHeight", RPCArg::Type::NUM, RPCArg::Default{-1}, "The height at which the message was signed.\n" "Only works when quorumHash is \"\"."}, }, @@ -788,7 +787,7 @@ static RPCHelpMan quorum_getdata() "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, /* default */ "", "The proTxHash the contributions will be requested for. Must be member of the specified LLMQ."}, + {"proTxHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "The proTxHash the contributions will be requested for. Must be member of the specified LLMQ."}, }, RPCResults{}, RPCExamples{""}, @@ -833,8 +832,8 @@ static RPCHelpMan quorum_rotationinfo() "Get quorum rotation information\n", { {"blockRequestHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The blockHash of the request."}, - {"extraShare", RPCArg::Type::BOOL, /* default */ "false", "Extra share"}, - {"baseBlockHash...", RPCArg::Type::STR_HEX, /* default*/ "", "baseBlockHashes"}, + {"extraShare", RPCArg::Type::BOOL, RPCArg::Default{false}, "Extra share"}, + {"baseBlockHash...", RPCArg::Type::STR_HEX, RPCArg::DefaultHint{"baseBlockHashes …"}, "The list of block hashes"}, }, RPCResults{}, RPCExamples{""}, @@ -955,7 +954,7 @@ static RPCHelpMan verifychainlock() { {"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."}, + {"blockHeight", RPCArg::Type::NUM, RPCArg::DefaultHint{"There will be an internal lookup of \"blockHash\" if this is not provided."}, "The height of the ChainLock."}, }, RPCResults{}, RPCExamples{""}, @@ -1013,7 +1012,7 @@ static RPCHelpMan verifyislock() {"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."}, + {"maxHeight", RPCArg::Type::NUM, RPCArg::Default{-1}, "The maximum height to search quorums from."}, }, RPCResults{}, RPCExamples{""}, diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index fca81b4c7e..e625436952 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{"depends on the value of the 'locktime' argument"}, "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" @@ -1035,7 +1035,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" @@ -1114,11 +1114,11 @@ 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"}, - {"bypasslimits", RPCArg::Type::BOOL, /* default_val */ "false", "Bypass transaction policy limits"}, + {"bypasslimits", RPCArg::Type::BOOL, RPCArg::Default{false}, "Bypass transaction policy limits"}, }, RPCResult{ RPCResult::Type::STR_HEX, "", "The transaction hash in hex" @@ -1184,7 +1184,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{ @@ -1619,7 +1619,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{ @@ -1681,7 +1681,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 the 'locktime' argument"}, "The sequence number"}, }, }, }, @@ -1691,7 +1691,7 @@ static RPCHelpMan createpsbt() "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" " accepted as second parameter.", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + {"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "", { {"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the Dash address, the value (float or string) is the amount in " + CURRENCY_UNIT}, }, @@ -1703,7 +1703,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)" @@ -1749,7 +1749,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{ @@ -1809,7 +1809,7 @@ static RPCHelpMan utxoupdatepsbt() {"", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "An output descriptor"}, {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with an output descriptor and extra information", { {"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"}, - {"range", RPCArg::Type::RANGE, "1000", "Up to what index HD chains should be explored (either end or [begin,end])"}, + {"range", RPCArg::Type::RANGE, RPCArg::Default{1000}, "Up to what index HD chains should be explored (either end or [begin,end])"}, }}, }}, }, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 0206f6c5b7..f6b88d42eb 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 ce0af11023..97b44915d2 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -480,6 +480,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; + } + } } } @@ -625,7 +652,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); @@ -673,7 +700,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 66edd95229..6ab21e2330 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -162,7 +162,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 16ac2596ab..4d75d2ae1c 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::Optional::OMITTED, "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 */ "", {"\"