Skip to content

Commit f81ef43

Browse files
committed
rpc: Keep default argument value in correct type
1 parent a12962c commit f81ef43

10 files changed

+187
-183
lines changed

src/rpc/blockchain.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static RPCHelpMan waitfornewblock()
239239
"\nWaits for a specific new block and returns useful info about it.\n"
240240
"\nReturns the current block on timeout or exit.\n",
241241
{
242-
{"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
242+
{"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in milliseconds to wait for a response. 0 indicates no timeout."},
243243
},
244244
RPCResult{
245245
RPCResult::Type::OBJ, "", "",
@@ -282,7 +282,7 @@ static RPCHelpMan waitforblock()
282282
"\nReturns the current block on timeout or exit.\n",
283283
{
284284
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Block hash to wait for."},
285-
{"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
285+
{"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in milliseconds to wait for a response. 0 indicates no timeout."},
286286
},
287287
RPCResult{
288288
RPCResult::Type::OBJ, "", "",
@@ -329,7 +329,7 @@ static RPCHelpMan waitforblockheight()
329329
"\nReturns the current block on timeout or exit.\n",
330330
{
331331
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "Block height to wait for."},
332-
{"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
332+
{"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in milliseconds to wait for a response. 0 indicates no timeout."},
333333
},
334334
RPCResult{
335335
RPCResult::Type::OBJ, "", "",
@@ -542,8 +542,8 @@ static RPCHelpMan getrawmempool()
542542
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
543543
"\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n",
544544
{
545-
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"},
546-
{"mempool_sequence", RPCArg::Type::BOOL, /* default */ "false", "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
545+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
546+
{"mempool_sequence", RPCArg::Type::BOOL, RPCArg::Default{false}, "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
547547
},
548548
{
549549
RPCResult{"for verbose = false",
@@ -592,7 +592,7 @@ static RPCHelpMan getmempoolancestors()
592592
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n",
593593
{
594594
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
595-
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"},
595+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
596596
},
597597
{
598598
RPCResult{"for verbose = false",
@@ -656,7 +656,7 @@ static RPCHelpMan getmempooldescendants()
656656
"\nIf txid is in the mempool, returns all in-mempool descendants.\n",
657657
{
658658
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
659-
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"},
659+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
660660
},
661661
{
662662
RPCResult{"for verbose = false",
@@ -782,7 +782,7 @@ static RPCHelpMan getblockheader()
782782
"If verbose is true, returns an Object with information about blockheader <hash>.\n",
783783
{
784784
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
785-
{"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"},
785+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for a json object, false for the hex-encoded data"},
786786
},
787787
{
788788
RPCResult{"for verbose = true",
@@ -883,7 +883,7 @@ static RPCHelpMan getblock()
883883
"If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n",
884884
{
885885
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
886-
{"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"},
886+
{"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"},
887887
},
888888
{
889889
RPCResult{"for verbosity = 0",
@@ -1046,7 +1046,7 @@ static RPCHelpMan gettxoutsetinfo()
10461046
"\nReturns statistics about the unspent transaction output set.\n"
10471047
"Note this call may take some time.\n",
10481048
{
1049-
{"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'."},
1049+
{"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'."},
10501050
},
10511051
RPCResult{
10521052
RPCResult::Type::OBJ, "", "",
@@ -1105,7 +1105,7 @@ static RPCHelpMan gettxout()
11051105
{
11061106
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
11071107
{"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"},
1108-
{"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."},
1108+
{"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."},
11091109
},
11101110
{
11111111
RPCResult{"If the UTXO was not found", RPCResult::Type::NONE, "", ""},
@@ -1185,9 +1185,9 @@ static RPCHelpMan verifychain()
11851185
return RPCHelpMan{"verifychain",
11861186
"\nVerifies blockchain database.\n",
11871187
{
1188-
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL),
1188+
{"checklevel", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL)},
11891189
strprintf("How thorough the block verification is:\n - %s", Join(CHECKLEVEL_DOC, "\n- "))},
1190-
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."},
1190+
{"nblocks", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS)}, "The number of blocks to check."},
11911191
},
11921192
RPCResult{
11931193
RPCResult::Type::BOOL, "", "Verified or not"},
@@ -1659,8 +1659,8 @@ static RPCHelpMan getchaintxstats()
16591659
return RPCHelpMan{"getchaintxstats",
16601660
"\nCompute statistics about the total number and rate of transactions in the chain.\n",
16611661
{
1662-
{"nblocks", RPCArg::Type::NUM, /* default */ "one month", "Size of the window in number of blocks"},
1663-
{"blockhash", RPCArg::Type::STR_HEX, /* default */ "chain tip", "The hash of the block that ends the window."},
1662+
{"nblocks", RPCArg::Type::NUM, RPCArg::DefaultHint{"one month"}, "Size of the window in number of blocks"},
1663+
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::DefaultHint{"chain tip"}, "The hash of the block that ends the window."},
16641664
},
16651665
RPCResult{
16661666
RPCResult::Type::OBJ, "", "",
@@ -1806,7 +1806,7 @@ static RPCHelpMan getblockstats()
18061806
"It won't work for some heights with pruning.\n",
18071807
{
18081808
{"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block hash or height of the target block", "", {"", "string or numeric"}},
1809-
{"stats", RPCArg::Type::ARR, /* default */ "all values", "Values to plot (see result below)",
1809+
{"stats", RPCArg::Type::ARR, RPCArg::DefaultHint{"all values"}, "Values to plot (see result below)",
18101810
{
18111811
{"height", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Selected statistic"},
18121812
{"time", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Selected statistic"},
@@ -2173,7 +2173,7 @@ static RPCHelpMan scantxoutset()
21732173
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with output descriptor and metadata",
21742174
{
21752175
{"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"},
2176-
{"range", RPCArg::Type::RANGE, /* default */ "1000", "The range of HD chain indexes to explore (either end or [begin,end])"},
2176+
{"range", RPCArg::Type::RANGE, RPCArg::Default{1000}, "The range of HD chain indexes to explore (either end or [begin,end])"},
21772177
}},
21782178
},
21792179
"[scanobjects,...]"},
@@ -2310,7 +2310,7 @@ static RPCHelpMan getblockfilter()
23102310
"\nRetrieve a BIP 157 content filter for a particular block.\n",
23112311
{
23122312
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hash of the block"},
2313-
{"filtertype", RPCArg::Type::STR, /*default*/ "basic", "The type name of the filter"},
2313+
{"filtertype", RPCArg::Type::STR, RPCArg::Default{"basic"}, "The type name of the filter"},
23142314
},
23152315
RPCResult{
23162316
RPCResult::Type::OBJ, "", "",

src/rpc/mining.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static RPCHelpMan getnetworkhashps()
8888
"Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
8989
"Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
9090
{
91-
{"nblocks", RPCArg::Type::NUM, /* default */ "120", "The number of blocks, or -1 for blocks since last difficulty change."},
92-
{"height", RPCArg::Type::NUM, /* default */ "-1", "To estimate at the time of the given height."},
91+
{"nblocks", RPCArg::Type::NUM, RPCArg::Default{120}, "The number of blocks, or -1 for blocks since last difficulty change."},
92+
{"height", RPCArg::Type::NUM, RPCArg::Default{-1}, "To estimate at the time of the given height."},
9393
},
9494
RPCResult{
9595
RPCResult::Type::NUM, "", "Hashes per second estimated"},
@@ -210,7 +210,7 @@ static RPCHelpMan generatetodescriptor()
210210
{
211211
{"num_blocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated immediately."},
212212
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor to send the newly generated bitcoin to."},
213-
{"maxtries", RPCArg::Type::NUM, /* default */ ToString(DEFAULT_MAX_TRIES), "How many iterations to try."},
213+
{"maxtries", RPCArg::Type::NUM, RPCArg::Default{DEFAULT_MAX_TRIES}, "How many iterations to try."},
214214
},
215215
RPCResult{
216216
RPCResult::Type::ARR, "", "hashes of blocks generated",
@@ -253,7 +253,7 @@ static RPCHelpMan generatetoaddress()
253253
{
254254
{"nblocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated immediately."},
255255
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address to send the newly generated bitcoin to."},
256-
{"maxtries", RPCArg::Type::NUM, /* default */ ToString(DEFAULT_MAX_TRIES), "How many iterations to try."},
256+
{"maxtries", RPCArg::Type::NUM, RPCArg::Default{DEFAULT_MAX_TRIES}, "How many iterations to try."},
257257
},
258258
RPCResult{
259259
RPCResult::Type::ARR, "", "hashes of blocks generated",
@@ -513,7 +513,7 @@ static RPCHelpMan getblocktemplate()
513513
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
514514
" https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
515515
{
516-
{"template_request", RPCArg::Type::OBJ, "{}", "Format of the template",
516+
{"template_request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "Format of the template",
517517
{
518518
{"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"},
519519
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
@@ -945,7 +945,7 @@ static RPCHelpMan submitblock()
945945
"See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n",
946946
{
947947
{"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded block data to submit"},
948-
{"dummy", RPCArg::Type::STR, /* default */ "ignored", "dummy value, for compatibility with BIP22. This value is ignored."},
948+
{"dummy", RPCArg::Type::STR, RPCArg::DefaultHint{"ignored"}, "dummy value, for compatibility with BIP22. This value is ignored."},
949949
},
950950
{
951951
RPCResult{"If the block was accepted", RPCResult::Type::NONE, "", ""},
@@ -1052,7 +1052,7 @@ static RPCHelpMan estimatesmartfee()
10521052
"in BIP 141 (witness data is discounted).\n",
10531053
{
10541054
{"conf_target", RPCArg::Type::NUM, RPCArg::Optional::NO, "Confirmation target in blocks (1 - 1008)"},
1055-
{"estimate_mode", RPCArg::Type::STR, /* default */ "conservative", "The fee estimate mode.\n"
1055+
{"estimate_mode", RPCArg::Type::STR, RPCArg::Default{"conservative"}, "The fee estimate mode.\n"
10561056
" Whether to return a more conservative estimate which also satisfies\n"
10571057
" a longer history. A conservative estimate potentially returns a\n"
10581058
" higher feerate and is more likely to be sufficient for the desired\n"
@@ -1123,7 +1123,7 @@ static RPCHelpMan estimaterawfee()
11231123
"defined in BIP 141 (witness data is discounted).\n",
11241124
{
11251125
{"conf_target", RPCArg::Type::NUM, RPCArg::Optional::NO, "Confirmation target in blocks (1 - 1008)"},
1126-
{"threshold", RPCArg::Type::NUM, /* default */ "0.95", "The proportion of transactions in a given feerate range that must have been\n"
1126+
{"threshold", RPCArg::Type::NUM, RPCArg::Default{0.95}, "The proportion of transactions in a given feerate range that must have been\n"
11271127
" confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n"
11281128
" lower buckets."},
11291129
},

src/rpc/misc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static RPCHelpMan createmultisig()
9090
{
9191
{"key", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "The hex-encoded public key"},
9292
}},
93-
{"address_type", RPCArg::Type::STR, /* default */ "legacy", "The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
93+
{"address_type", RPCArg::Type::STR, RPCArg::Default{"legacy"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
9494
},
9595
RPCResult{
9696
RPCResult::Type::OBJ, "", "",
@@ -475,7 +475,7 @@ static RPCHelpMan getmemoryinfo()
475475
return RPCHelpMan{"getmemoryinfo",
476476
"Returns an object containing information about memory usage.\n",
477477
{
478-
{"mode", RPCArg::Type::STR, /* default */ "\"stats\"", "determines what kind of information is returned.\n"
478+
{"mode", RPCArg::Type::STR, RPCArg::Default{"stats"}, "determines what kind of information is returned.\n"
479479
" - \"stats\" returns general statistics about memory usage in the daemon.\n"
480480
" - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+)."},
481481
},

0 commit comments

Comments
 (0)