You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge bitcoin#21679: rpc: Keep default argument value in correct type
bee56c7 rpc: Check default value type againts argument type (João Barbosa)
f81ef43 rpc: Keep default argument value in correct type (João Barbosa)
Pull request description:
Store default values of RPC arguments in the corresponding type instead of a string. The value is then serialized when the help output is needed. This change simplifies bitcoin#20017.
The following examples illustrates how to use the new `RPCArg::Default` and `RPCArg::DefaultHint`:
```diff
- {"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"}
```
```diff
- {"nblocks", RPCArg::Type::NUM, /* default */ "one month", "Size of the window in number of blocks"}
+ {"nblocks", RPCArg::Type::NUM, RPCArg::DefaultHint("one month"), "Size of the window in number of blocks"}
```
No behavior change is expected.
ACKs for top commit:
LarryRuane:
ACK bee56c7
MarcoFalke:
ACK bee56c7 🦅
Tree-SHA512: c47d78c918e996d36631d4ad3c933b270a34c5b446b8d736be94cf4a0a7b8c0e33d954149ec786cf9550639865b79deb6a130ad044de6030f95aac33f524293a
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
580
581
"\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n",
581
582
{
582
-
{"verbose", RPCArg::Type::BOOL, /* default */"false", "True for a json object, false for array of transaction ids"},
583
-
{"mempool_sequence", RPCArg::Type::BOOL, /* default */"false", "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
583
+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
584
+
{"mempool_sequence", RPCArg::Type::BOOL, RPCArg::Default{false}, "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
"If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n",
1211
1212
{
1212
1213
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
1213
-
{"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"},
1214
+
{"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"},
"\nReturns statistics about the unspent transaction output set.\n"
1388
1389
"Note this call may take some time if you are not using coinstatsindex.\n",
1389
1390
{
1390
-
{"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'."},
1391
+
{"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'."},
1391
1392
{"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"}},
1392
-
{"use_index", RPCArg::Type::BOOL, /* default */"true", "Use coinstatsindex, if available."},
1393
+
{"use_index", RPCArg::Type::BOOL, RPCArg::Default{true}, "Use coinstatsindex, if available."},
{"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."},
1535
+
{"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."},
1535
1536
},
1536
1537
{
1537
1538
RPCResult{"If the UTXO was not found", RPCResult::Type::NONE, "", ""},
{"template_request", RPCArg::Type::OBJ, /* default_val */"", "Format of the template",
566
+
{"template_request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "Format of the template",
567
567
{
568
568
{"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"},
569
569
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
0 commit comments