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 #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 #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"
559
559
"\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n",
560
560
{
561
-
{"verbose", RPCArg::Type::BOOL, /* default */"false", "True for a json object, false for array of transaction ids"},
562
-
{"mempool_sequence", RPCArg::Type::BOOL, /* default */"false", "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
561
+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
562
+
{"mempool_sequence", RPCArg::Type::BOOL, RPCArg::Default{false}, "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
"If verbose is true, returns an Object with information about blockheader <hash>.\n",
801
801
{
802
802
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
803
-
{"verbose", RPCArg::Type::BOOL, /* default */"true", "true for a json object, false for the hex-encoded data"},
803
+
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for a json object, false for the hex-encoded data"},
804
804
},
805
805
{
806
806
RPCResult{"for verbose = true",
@@ -902,7 +902,7 @@ static RPCHelpMan getblock()
902
902
"If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n",
903
903
{
904
904
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
905
-
{"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"},
905
+
{"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"
1071
1071
"Note this call may take some time.\n",
1072
1072
{
1073
-
{"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'."},
1073
+
{"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'."},
{"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."},
1140
+
{"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."},
1141
1141
},
1142
1142
{
1143
1143
RPCResult{"If the UTXO was not found", RPCResult::Type::NONE, "", ""},
{"template_request", RPCArg::Type::OBJ, "{}", "Format of the template",
528
+
{"template_request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "Format of the template",
529
529
{
530
530
{"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"},
531
531
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
0 commit comments