Repository: bitcoin/bitcoin
File: src/rpc/client.cpp (C++)

Code before:
 * @note Parameter indexes start from 0.
 */
static const CRPCConvertParam vRPCConvertParams[] =
{
    { "setmocktime", 0, "timestamp" },
    { "mockscheduler", 0, "delta_time" },
    { "utxoupdatepsbt", 1, "descriptors" },
    { "generatetoaddress", 0, "nblocks" },
    { "generatetoaddress", 2, "maxtries" },
    { "generatetodescriptor", 0, "num_blocks" },
    { "generatetodescriptor", 2, "maxtries" },
    { "generateblock", 1, "transactions" },
    { "generateblock", 2, "submit" },
    { "getnetworkhashps", 0, "nblocks" },
    { "getnetworkhashps", 1, "height" },
    { "sendtoaddress", 1, "amount" },
    { "sendtoaddress", 4, "subtractfeefromamount" },
    { "sendtoaddress", 5 , "replaceable" },
    { "sendtoaddress", 6 , "conf_target" },
    { "sendtoaddress", 8, "avoid_reuse" },
    { "sendtoaddress", 9, "fee_rate"},
    { "sendtoaddress", 10, "verbose"},
    { "settxfee", 0, "amount" },
    { "getreceivedbyaddress", 1, "minconf" },
    { "getreceivedbyaddress", 2, "include_immature_coinbase" },
    { "getreceivedbylabel", 1, "minconf" },
    { "getreceivedbylabel", 2, "include_immature_coinbase" },
    { "listreceivedbyaddress", 0, "minconf" },
    { "listreceivedbyaddress", 1, "include_empty" },
    { "listreceivedbyaddress", 2, "include_watchonly" },
    { "listreceivedbyaddress", 4, "include_immature_coinbase" },
    { "listreceivedbylabel", 0, "minconf" },
    { "listreceivedbylabel", 1, "include_empty" },
    { "listreceivedbylabel", 2, "include_watchonly" },
    { "listreceivedbylabel", 3, "include_immature_coinbase" },
    { "getbalance", 1, "minconf" },
    { "getbalance", 2, "include_watchonly" },
    { "getbalance", 3, "avoid_reuse" },
    { "getblockfrompeer", 1, "peer_id" },
    { "getblockhash", 0, "height" },
    { "waitforblockheight", 0, "height" },
    { "waitforblockheight", 1, "timeout" },
    { "waitforblock", 1, "timeout" },
    { "waitfornewblock", 0, "timeout" },
    { "listtransactions", 1, "count" },
    { "listtransactions", 2, "skip" },
    { "listtransactions", 3, "include_watchonly" },
    { "walletpassphrase", 1, "timeout" },
    { "getblocktemplate", 0, "template_request" },
    { "listsinceblock", 1, "target_confirmations" },
    { "listsinceblock", 2, "include_watchonly" },

Review comment (bug):
In commit "rpc: Handle -named argument parsing where '=' character is used" (04e78595410c557c970eb3994a40586231d5b38e)

This new paragraph is nice, but I think it would make sense to move it earlier in the description so JSON parameters (which are more important to list) are covered first, and STRING parameters (which are less important to list) are covered second). This should also be clearer than talking about JSON parameters, then string parameters, then JSON parameters again. Would suggest something like:

<details><summary>diff</summary>
<p>

```diff
--- a/src/rpc/client.cpp
+++ b/src/rpc/client.cpp
@@ -31,8 +31,14 @@ public:
  * argument and needs to be converted from JSON, or if it is a string argument
  * passed to a method that accepts '=' characters in any string arguments.
  *
- * JSON parameters need to be listed here to make bitcoin-cli treat command line
- * arguments as JSON values instead of strings.
+ * JSON parameters need to be listed here to make bitcoin-cli parse command line
+ * arguments as JSON, instead of passing them as raw strings. `JSON` and
+ * `JSON_OR_STRING` formats both make `bitcoin-cli` attempt to parse the
+ * argument as JSON. But if parsing fails, the former triggers an error while
+ * the latter falls back to passing the argument as a raw string. This is
+ * useful for arguments like hash_or_height, allowing invocations such as
+ * `bitcoin-cli getblockstats <hash>` without needing to quote the hash string
+ * as JSON (`'"<hash>"'`).
  *
  * String parameters that may contain an '=' character (e.g. base64 strings,
  * filenames, or labels) need to be listed here with format `ParamFormat::STRING`
@@ -46,13 +52,6 @@ public:
  * for more information on how named and positional arguments are distinguished with
  * -named.
  *
- * Parameters that can be either a JSON value or a string should be listed
- * with format `ParamFormat::JSON_OR_STRING`. This makes bitcoin-cli first attempt
- * to parse the argument as JSON. If parsing fails, it falls back to treating the
- * argument as a raw string. This is useful for arguments like hash_or_height,
- * allowing invocations such as `bitcoin-cli getblockstats <hash>` without
- * needing to quote the hash string as JSON (`'"<hash>"'`).
- *
  * @note Parameter indexes start from 0.
  */
 static const CRPCConvertParam vRPCConvertParams[] =
```
</p>
</details>

Code after:
/**
 * Specify a (method, idx, name, format) here if the argument is a non-string RPC
 * argument and needs to be converted from JSON, or if it is a string argument
 * passed to a method that accepts '=' characters in any string arguments.
 *
 * JSON parameters need to be listed here to make bitcoin-cli parse command line
 * arguments as JSON, instead of passing them as raw strings. `JSON` and
 * `JSON_OR_STRING` formats both make `bitcoin-cli` attempt to parse the
 * argument as JSON. But if parsing fails, the former triggers an error while
 * the latter falls back to passing the argument as a raw string. This is
 * useful for arguments like hash_or_height, allowing invocations such as
 * `bitcoin-cli getblockstats <hash>` without needing to quote the hash string
 * as JSON (`'"<hash>"'`).
 *
 * String parameters that may contain an '=' character (e.g. base64 strings,
 * filenames, or labels) need to be listed here with format `ParamFormat::STRING`
 * to make bitcoin-cli treat them as positional parameters when `-named` is used.
 * This prevents `bitcoin-cli` from splitting strings like "my=wallet" into a named
 * argument "my" and value "wallet" when the whole string is intended to be a
 * single positional argument. And if one string parameter is listed for a method,
 * other string parameters for that method need to be listed as well so bitcoin-cli
 * does not make the opposite mistake and pass other arguments by position instead of
 * name because it does not recognize their names. See \ref RPCConvertNamedValues
 * for more information on how named and positional arguments are distinguished with
 * -named.
 *
 * @note Parameter indexes start from 0.
 */
static const CRPCConvertParam vRPCConvertParams[] =
{
    { "setmocktime", 0, "timestamp" },
    { "mockscheduler", 0, "delta_time" },
    { "utxoupdatepsbt", 0, "psbt", ParamFormat::STRING },
    { "utxoupdatepsbt", 1, "descriptors" },
    { "generatetoaddress", 0, "nblocks" },
    { "generatetoaddress", 2, "maxtries" },
    { "generatetodescriptor", 0, "num_blocks" },
    { "generatetodescriptor", 2, "maxtries" },
    { "generateblock", 1, "transactions" },
    { "generateblock", 2, "submit" },
    { "getnetworkhashps", 0, "nblocks" },
    { "getnetworkhashps", 1, "height" },
    { "sendtoaddress", 0, "address", ParamFormat::STRING },
    { "sendtoaddress", 1, "amount" },
    { "sendtoaddress", 2, "comment", ParamFormat::STRING },
    { "sendtoaddress", 3, "comment_to", ParamFormat::STRING },
    { "sendtoaddress", 4, "subtractfeefromamount" },
    { "sendtoaddress", 5 , "replaceable" },
    { "sendtoaddress", 6 , "conf_target" },
    { "sendtoaddress", 7, "estimate_mode", ParamFormat::STRING },
    { "sendtoaddress", 8, "avoid_reuse" },