LCOV - code coverage report
Current view: top level - src/rpc - client.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 315 316 99.7 %
Date: 2023-10-05 15:40:34 Functions: 11 11 100.0 %
Branches: 599 1718 34.9 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2010 Satoshi Nakamoto
       2                 :            : // Copyright (c) 2009-2022 The Bitcoin Core developers
       3                 :            : // Distributed under the MIT software license, see the accompanying
       4                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5                 :            : 
       6                 :            : #include <common/args.h>
       7                 :            : #include <rpc/client.h>
       8                 :            : #include <tinyformat.h>
       9                 :            : 
      10                 :            : #include <set>
      11                 :            : #include <stdint.h>
      12                 :            : #include <string>
      13                 :            : #include <string_view>
      14                 :            : 
      15                 :            : class CRPCConvertParam
      16                 :            : {
      17                 :            : public:
      18                 :            :     std::string methodName; //!< method whose params want conversion
      19                 :            :     int paramIdx;           //!< 0-based idx of param to convert
      20                 :            :     std::string paramName;  //!< parameter name
      21                 :            : };
      22                 :            : 
      23                 :            : // clang-format off
      24                 :            : /**
      25                 :            :  * Specify a (method, idx, name) here if the argument is a non-string RPC
      26                 :            :  * argument and needs to be converted from JSON.
      27                 :            :  *
      28                 :            :  * @note Parameter indexes start from 0.
      29                 :            :  */
      30                 :          0 : static const CRPCConvertParam vRPCConvertParams[] =
      31   [ #  #  #  #  :      47229 : {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
      32   [ +  -  +  - ]:        173 :     { "setmocktime", 0, "timestamp" },
      33   [ +  -  +  - ]:        173 :     { "mockscheduler", 0, "delta_time" },
      34   [ +  -  +  - ]:        173 :     { "utxoupdatepsbt", 1, "descriptors" },
      35   [ +  -  +  - ]:        173 :     { "generatetoaddress", 0, "nblocks" },
      36   [ +  -  +  - ]:        173 :     { "generatetoaddress", 2, "maxtries" },
      37   [ +  -  +  - ]:        173 :     { "generatetodescriptor", 0, "num_blocks" },
      38   [ +  -  +  - ]:        173 :     { "generatetodescriptor", 2, "maxtries" },
      39   [ +  -  +  - ]:        173 :     { "generateblock", 1, "transactions" },
      40   [ +  -  +  - ]:        173 :     { "generateblock", 2, "submit" },
      41   [ +  -  +  - ]:        173 :     { "getnetworkhashps", 0, "nblocks" },
      42   [ +  -  +  - ]:        173 :     { "getnetworkhashps", 1, "height" },
      43   [ +  -  +  - ]:        173 :     { "sendtoaddress", 1, "amount" },
      44   [ +  -  +  - ]:        173 :     { "sendtoaddress", 4, "subtractfeefromamount" },
      45   [ +  -  +  - ]:        173 :     { "sendtoaddress", 5 , "replaceable" },
      46   [ +  -  +  - ]:        173 :     { "sendtoaddress", 6 , "conf_target" },
      47   [ +  -  +  - ]:        173 :     { "sendtoaddress", 8, "avoid_reuse" },
      48   [ +  -  +  - ]:        173 :     { "sendtoaddress", 9, "fee_rate"},
      49   [ +  -  +  - ]:        173 :     { "sendtoaddress", 10, "verbose"},
      50   [ +  -  +  - ]:        173 :     { "settxfee", 0, "amount" },
      51   [ +  -  +  - ]:        173 :     { "sethdseed", 0, "newkeypool" },
      52   [ +  -  +  - ]:        173 :     { "getreceivedbyaddress", 1, "minconf" },
      53   [ +  -  +  - ]:        173 :     { "getreceivedbyaddress", 2, "include_immature_coinbase" },
      54   [ +  -  +  - ]:        173 :     { "getreceivedbylabel", 1, "minconf" },
      55   [ +  -  +  - ]:        173 :     { "getreceivedbylabel", 2, "include_immature_coinbase" },
      56   [ +  -  +  - ]:        173 :     { "listreceivedbyaddress", 0, "minconf" },
      57   [ +  -  +  - ]:        173 :     { "listreceivedbyaddress", 1, "include_empty" },
      58   [ +  -  +  - ]:        173 :     { "listreceivedbyaddress", 2, "include_watchonly" },
      59   [ +  -  +  - ]:        173 :     { "listreceivedbyaddress", 4, "include_immature_coinbase" },
      60   [ +  -  +  - ]:        173 :     { "listreceivedbylabel", 0, "minconf" },
      61   [ +  -  +  - ]:        173 :     { "listreceivedbylabel", 1, "include_empty" },
      62   [ +  -  +  - ]:        173 :     { "listreceivedbylabel", 2, "include_watchonly" },
      63   [ +  -  +  - ]:        173 :     { "listreceivedbylabel", 3, "include_immature_coinbase" },
      64   [ +  -  +  - ]:        173 :     { "getbalance", 1, "minconf" },
      65   [ +  -  +  - ]:        173 :     { "getbalance", 2, "include_watchonly" },
      66   [ +  -  +  - ]:        173 :     { "getbalance", 3, "avoid_reuse" },
      67   [ +  -  +  - ]:        173 :     { "getblockfrompeer", 1, "peer_id" },
      68   [ +  -  +  - ]:        173 :     { "getblockhash", 0, "height" },
      69   [ +  -  +  - ]:        173 :     { "waitforblockheight", 0, "height" },
      70   [ +  -  +  - ]:        173 :     { "waitforblockheight", 1, "timeout" },
      71   [ +  -  +  - ]:        173 :     { "waitforblock", 1, "timeout" },
      72   [ +  -  +  - ]:        173 :     { "waitfornewblock", 0, "timeout" },
      73   [ +  -  +  - ]:        173 :     { "listtransactions", 1, "count" },
      74   [ +  -  +  - ]:        346 :     { "listtransactions", 2, "skip" },
      75   [ +  -  +  - ]:        173 :     { "listtransactions", 3, "include_watchonly" },
      76   [ +  -  +  - ]:        173 :     { "walletpassphrase", 1, "timeout" },
      77   [ +  -  +  - ]:        173 :     { "getblocktemplate", 0, "template_request" },
      78   [ +  -  +  - ]:        173 :     { "listsinceblock", 1, "target_confirmations" },
      79   [ +  -  +  - ]:        173 :     { "listsinceblock", 2, "include_watchonly" },
      80   [ +  -  +  - ]:        173 :     { "listsinceblock", 3, "include_removed" },
      81   [ +  -  +  - ]:        173 :     { "listsinceblock", 4, "include_change" },
      82   [ +  -  +  - ]:        173 :     { "sendmany", 1, "amounts" },
      83   [ +  -  +  - ]:        173 :     { "sendmany", 2, "minconf" },
      84   [ +  -  +  - ]:        173 :     { "sendmany", 4, "subtractfeefrom" },
      85   [ +  -  +  - ]:        173 :     { "sendmany", 5 , "replaceable" },
      86   [ +  -  +  - ]:        173 :     { "sendmany", 6 , "conf_target" },
      87   [ +  -  +  - ]:        173 :     { "sendmany", 8, "fee_rate"},
      88   [ +  -  +  - ]:        173 :     { "sendmany", 9, "verbose" },
      89   [ +  -  +  - ]:        173 :     { "deriveaddresses", 1, "range" },
      90   [ +  -  +  - ]:        173 :     { "scanblocks", 1, "scanobjects" },
      91   [ +  -  +  - ]:        173 :     { "scanblocks", 2, "start_height" },
      92   [ +  -  +  - ]:        173 :     { "scanblocks", 3, "stop_height" },
      93   [ +  -  +  - ]:        173 :     { "scanblocks", 5, "options" },
      94   [ +  -  +  - ]:        173 :     { "scantxoutset", 1, "scanobjects" },
      95   [ +  -  +  - ]:        173 :     { "addmultisigaddress", 0, "nrequired" },
      96   [ +  -  +  - ]:        173 :     { "addmultisigaddress", 1, "keys" },
      97   [ +  -  +  - ]:        173 :     { "createmultisig", 0, "nrequired" },
      98   [ +  -  +  - ]:        173 :     { "createmultisig", 1, "keys" },
      99   [ +  -  +  - ]:        173 :     { "listunspent", 0, "minconf" },
     100   [ +  -  +  - ]:        173 :     { "listunspent", 1, "maxconf" },
     101   [ +  -  +  - ]:        173 :     { "listunspent", 2, "addresses" },
     102   [ +  -  +  - ]:        173 :     { "listunspent", 3, "include_unsafe" },
     103   [ +  -  +  - ]:        173 :     { "listunspent", 4, "query_options" },
     104   [ +  -  +  - ]:        173 :     { "listunspent", 4, "minimumAmount" },
     105   [ +  -  +  - ]:        173 :     { "listunspent", 4, "maximumAmount" },
     106   [ +  -  +  - ]:        173 :     { "listunspent", 4, "maximumCount" },
     107   [ +  -  +  - ]:        173 :     { "listunspent", 4, "minimumSumAmount" },
     108   [ +  -  +  - ]:        173 :     { "listunspent", 4, "include_immature_coinbase" },
     109   [ +  -  +  - ]:        173 :     { "getblock", 1, "verbosity" },
     110   [ +  -  +  - ]:        173 :     { "getblock", 1, "verbose" },
     111   [ +  -  +  - ]:        173 :     { "getblockheader", 1, "verbose" },
     112   [ +  -  +  - ]:        173 :     { "getchaintxstats", 0, "nblocks" },
     113   [ +  -  +  - ]:        173 :     { "gettransaction", 1, "include_watchonly" },
     114   [ +  -  +  - ]:        173 :     { "gettransaction", 2, "verbose" },
     115   [ +  -  +  - ]:        173 :     { "getrawtransaction", 1, "verbosity" },
     116   [ +  -  +  - ]:        173 :     { "getrawtransaction", 1, "verbose" },
     117   [ +  -  +  - ]:        173 :     { "createrawtransaction", 0, "inputs" },
     118   [ +  -  +  - ]:        173 :     { "createrawtransaction", 1, "outputs" },
     119   [ +  -  +  - ]:        173 :     { "createrawtransaction", 2, "locktime" },
     120   [ +  -  +  - ]:        173 :     { "createrawtransaction", 3, "replaceable" },
     121   [ +  -  +  - ]:        173 :     { "decoderawtransaction", 1, "iswitness" },
     122   [ +  -  +  - ]:        173 :     { "signrawtransactionwithkey", 1, "privkeys" },
     123   [ +  -  +  - ]:        173 :     { "signrawtransactionwithkey", 2, "prevtxs" },
     124   [ +  -  +  - ]:        173 :     { "signrawtransactionwithwallet", 1, "prevtxs" },
     125   [ +  -  +  - ]:        173 :     { "sendrawtransaction", 1, "maxfeerate" },
     126   [ +  -  +  - ]:        173 :     { "sendrawtransaction", 2, "maxburnamount" },
     127   [ +  -  +  - ]:        173 :     { "testmempoolaccept", 0, "rawtxs" },
     128   [ +  -  +  - ]:        173 :     { "testmempoolaccept", 1, "maxfeerate" },
     129   [ +  -  +  - ]:        173 :     { "submitpackage", 0, "package" },
     130   [ +  -  +  - ]:        173 :     { "combinerawtransaction", 0, "txs" },
     131   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "options" },
     132   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "add_inputs"},
     133   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "include_unsafe"},
     134   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "minconf"},
     135   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "maxconf"},
     136   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "changePosition"},
     137   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "includeWatching"},
     138   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "lockUnspents"},
     139   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "fee_rate"},
     140   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "feeRate"},
     141   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "subtractFeeFromOutputs"},
     142   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "input_weights"},
     143   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "conf_target"},
     144   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "replaceable"},
     145   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 1, "solving_data"},
     146   [ +  -  +  - ]:        173 :     { "fundrawtransaction", 2, "iswitness" },
     147   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 0, "inputs" },
     148   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 1, "outputs" },
     149   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 2, "locktime" },
     150   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "options" },
     151   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "add_inputs"},
     152   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "include_unsafe"},
     153   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "minconf"},
     154   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "maxconf"},
     155   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "changePosition"},
     156   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "includeWatching"},
     157   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "lockUnspents"},
     158   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "fee_rate"},
     159   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "feeRate"},
     160   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "subtractFeeFromOutputs"},
     161   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "conf_target"},
     162   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "replaceable"},
     163   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 3, "solving_data"},
     164   [ +  -  +  - ]:        173 :     { "walletcreatefundedpsbt", 4, "bip32derivs" },
     165   [ +  -  +  - ]:        173 :     { "walletprocesspsbt", 1, "sign" },
     166   [ +  -  +  - ]:        173 :     { "walletprocesspsbt", 3, "bip32derivs" },
     167   [ +  -  +  - ]:        173 :     { "walletprocesspsbt", 4, "finalize" },
     168   [ +  -  +  - ]:        173 :     { "descriptorprocesspsbt", 1, "descriptors"},
     169   [ +  -  +  - ]:        173 :     { "descriptorprocesspsbt", 3, "bip32derivs" },
     170   [ +  -  +  - ]:        173 :     { "descriptorprocesspsbt", 4, "finalize" },
     171   [ +  -  +  - ]:        173 :     { "createpsbt", 0, "inputs" },
     172   [ +  -  +  - ]:        173 :     { "createpsbt", 1, "outputs" },
     173   [ +  -  +  - ]:        173 :     { "createpsbt", 2, "locktime" },
     174   [ +  -  +  - ]:        173 :     { "createpsbt", 3, "replaceable" },
     175   [ +  -  +  - ]:        173 :     { "combinepsbt", 0, "txs"},
     176   [ +  -  +  - ]:        173 :     { "joinpsbts", 0, "txs"},
     177   [ +  -  +  - ]:        173 :     { "finalizepsbt", 1, "extract"},
     178   [ +  -  +  - ]:        173 :     { "converttopsbt", 1, "permitsigdata"},
     179   [ +  -  +  - ]:        173 :     { "converttopsbt", 2, "iswitness"},
     180   [ +  -  +  - ]:        173 :     { "gettxout", 1, "n" },
     181   [ +  -  +  - ]:        173 :     { "gettxout", 2, "include_mempool" },
     182   [ +  -  +  - ]:        173 :     { "gettxoutproof", 0, "txids" },
     183   [ +  -  +  - ]:        173 :     { "gettxoutsetinfo", 1, "hash_or_height" },
     184   [ +  -  +  - ]:        173 :     { "gettxoutsetinfo", 2, "use_index"},
     185   [ +  -  +  - ]:        173 :     { "lockunspent", 0, "unlock" },
     186   [ +  -  +  - ]:        173 :     { "lockunspent", 1, "transactions" },
     187   [ +  -  +  - ]:        173 :     { "lockunspent", 2, "persistent" },
     188   [ +  -  +  - ]:        173 :     { "send", 0, "outputs" },
     189   [ +  -  +  - ]:        173 :     { "send", 1, "conf_target" },
     190   [ +  -  +  - ]:        173 :     { "send", 3, "fee_rate"},
     191   [ +  -  +  - ]:        173 :     { "send", 4, "options" },
     192   [ +  -  +  - ]:        173 :     { "send", 4, "add_inputs"},
     193   [ +  -  +  - ]:        173 :     { "send", 4, "include_unsafe"},
     194   [ +  -  +  - ]:        173 :     { "send", 4, "minconf"},
     195   [ +  -  +  - ]:        173 :     { "send", 4, "maxconf"},
     196   [ +  -  +  - ]:        173 :     { "send", 4, "add_to_wallet"},
     197   [ +  -  +  - ]:        173 :     { "send", 4, "change_position"},
     198   [ +  -  +  - ]:        173 :     { "send", 4, "fee_rate"},
     199   [ +  -  +  - ]:        173 :     { "send", 4, "include_watching"},
     200   [ +  -  +  - ]:        173 :     { "send", 4, "inputs"},
     201   [ +  -  +  - ]:        173 :     { "send", 4, "locktime"},
     202   [ +  -  +  - ]:        173 :     { "send", 4, "lock_unspents"},
     203   [ +  -  +  - ]:        173 :     { "send", 4, "psbt"},
     204   [ +  -  +  - ]:        173 :     { "send", 4, "subtract_fee_from_outputs"},
     205   [ +  -  +  - ]:        173 :     { "send", 4, "conf_target"},
     206   [ +  -  +  - ]:        173 :     { "send", 4, "replaceable"},
     207   [ +  -  +  - ]:        173 :     { "send", 4, "solving_data"},
     208   [ +  -  +  - ]:        173 :     { "sendall", 0, "recipients" },
     209   [ +  -  +  - ]:        173 :     { "sendall", 1, "conf_target" },
     210   [ +  -  +  - ]:        173 :     { "sendall", 3, "fee_rate"},
     211   [ +  -  +  - ]:        173 :     { "sendall", 4, "options" },
     212   [ +  -  +  - ]:        173 :     { "sendall", 4, "add_to_wallet"},
     213   [ +  -  +  - ]:        173 :     { "sendall", 4, "fee_rate"},
     214   [ +  -  +  - ]:        173 :     { "sendall", 4, "include_watching"},
     215   [ +  -  +  - ]:        173 :     { "sendall", 4, "inputs"},
     216   [ +  -  +  - ]:        173 :     { "sendall", 4, "locktime"},
     217   [ +  -  +  - ]:        173 :     { "sendall", 4, "lock_unspents"},
     218   [ +  -  +  - ]:        173 :     { "sendall", 4, "psbt"},
     219   [ +  -  +  - ]:        173 :     { "sendall", 4, "send_max"},
     220   [ +  -  +  - ]:        173 :     { "sendall", 4, "minconf"},
     221   [ +  -  +  - ]:        173 :     { "sendall", 4, "maxconf"},
     222   [ +  -  +  - ]:        173 :     { "sendall", 4, "conf_target"},
     223   [ +  -  +  - ]:        173 :     { "sendall", 4, "replaceable"},
     224   [ +  -  +  - ]:        173 :     { "sendall", 4, "solving_data"},
     225   [ +  -  +  - ]:        173 :     { "simulaterawtransaction", 0, "rawtxs" },
     226   [ +  -  +  - ]:        173 :     { "simulaterawtransaction", 1, "options" },
     227   [ +  -  +  - ]:        173 :     { "simulaterawtransaction", 1, "include_watchonly"},
     228   [ +  -  +  - ]:        173 :     { "importprivkey", 2, "rescan" },
     229   [ +  -  +  - ]:        173 :     { "importaddress", 2, "rescan" },
     230   [ +  -  +  - ]:        173 :     { "importaddress", 3, "p2sh" },
     231   [ +  -  +  - ]:        173 :     { "importpubkey", 2, "rescan" },
     232   [ +  -  +  - ]:        173 :     { "importmempool", 1, "options" },
     233   [ +  -  +  - ]:        173 :     { "importmempool", 1, "apply_fee_delta_priority" },
     234   [ +  -  +  - ]:        173 :     { "importmempool", 1, "use_current_time" },
     235   [ +  -  +  - ]:        173 :     { "importmempool", 1, "apply_unbroadcast_set" },
     236   [ +  -  +  - ]:        173 :     { "importmulti", 0, "requests" },
     237   [ +  -  +  - ]:        173 :     { "importmulti", 1, "options" },
     238   [ +  -  +  - ]:        173 :     { "importmulti", 1, "rescan" },
     239   [ +  -  +  - ]:        173 :     { "importdescriptors", 0, "requests" },
     240   [ +  -  +  - ]:        173 :     { "listdescriptors", 0, "private" },
     241   [ +  -  +  - ]:        173 :     { "verifychain", 0, "checklevel" },
     242   [ +  -  +  - ]:        173 :     { "verifychain", 1, "nblocks" },
     243   [ +  -  +  - ]:        173 :     { "getblockstats", 0, "hash_or_height" },
     244   [ +  -  +  - ]:        173 :     { "getblockstats", 1, "stats" },
     245   [ +  -  +  - ]:        173 :     { "pruneblockchain", 0, "height" },
     246   [ +  -  +  - ]:        173 :     { "keypoolrefill", 0, "newsize" },
     247   [ +  -  +  - ]:        173 :     { "getrawmempool", 0, "verbose" },
     248   [ +  -  +  - ]:        173 :     { "getrawmempool", 1, "mempool_sequence" },
     249   [ +  -  +  - ]:        173 :     { "estimatesmartfee", 0, "conf_target" },
     250   [ +  -  +  - ]:        173 :     { "estimaterawfee", 0, "conf_target" },
     251   [ +  -  +  - ]:        173 :     { "estimaterawfee", 1, "threshold" },
     252   [ +  -  +  - ]:        173 :     { "prioritisetransaction", 1, "dummy" },
     253   [ +  -  +  - ]:        173 :     { "prioritisetransaction", 2, "fee_delta" },
     254   [ +  -  +  - ]:        173 :     { "setban", 2, "bantime" },
     255   [ +  -  +  - ]:        173 :     { "setban", 3, "absolute" },
     256   [ +  -  +  - ]:        173 :     { "setnetworkactive", 0, "state" },
     257   [ +  -  +  - ]:        173 :     { "setwalletflag", 1, "value" },
     258   [ +  -  +  - ]:        173 :     { "getmempoolancestors", 1, "verbose" },
     259   [ +  -  +  - ]:        173 :     { "getmempooldescendants", 1, "verbose" },
     260   [ +  -  +  - ]:        173 :     { "gettxspendingprevout", 0, "outputs" },
     261   [ +  -  +  - ]:        173 :     { "bumpfee", 1, "options" },
     262   [ +  -  +  - ]:        173 :     { "bumpfee", 1, "conf_target"},
     263   [ +  -  +  - ]:        173 :     { "bumpfee", 1, "fee_rate"},
     264   [ +  -  +  - ]:        173 :     { "bumpfee", 1, "replaceable"},
     265   [ +  -  +  - ]:        173 :     { "bumpfee", 1, "outputs"},
     266   [ +  -  +  - ]:        173 :     { "bumpfee", 1, "original_change_index"},
     267   [ +  -  +  - ]:        173 :     { "psbtbumpfee", 1, "options" },
     268   [ +  -  +  - ]:        173 :     { "psbtbumpfee", 1, "conf_target"},
     269   [ +  -  +  - ]:        173 :     { "psbtbumpfee", 1, "fee_rate"},
     270   [ +  -  +  - ]:        173 :     { "psbtbumpfee", 1, "replaceable"},
     271   [ +  -  +  - ]:        173 :     { "psbtbumpfee", 1, "outputs"},
     272   [ +  -  +  - ]:        173 :     { "psbtbumpfee", 1, "original_change_index"},
     273   [ +  -  +  - ]:        173 :     { "logging", 0, "include" },
     274   [ +  -  +  - ]:        173 :     { "logging", 1, "exclude" },
     275   [ +  -  +  - ]:        173 :     { "disconnectnode", 1, "nodeid" },
     276   [ +  -  +  - ]:        173 :     { "upgradewallet", 0, "version" },
     277                 :            :     // Echo with conversion (For testing only)
     278   [ +  -  +  - ]:        173 :     { "echojson", 0, "arg0" },
     279   [ +  -  +  - ]:        173 :     { "echojson", 1, "arg1" },
     280   [ +  -  +  - ]:        173 :     { "echojson", 2, "arg2" },
     281   [ +  -  +  - ]:        173 :     { "echojson", 3, "arg3" },
     282   [ +  -  +  - ]:        173 :     { "echojson", 4, "arg4" },
     283   [ +  -  +  - ]:        173 :     { "echojson", 5, "arg5" },
     284   [ +  -  +  - ]:        173 :     { "echojson", 6, "arg6" },
     285   [ +  -  +  - ]:        173 :     { "echojson", 7, "arg7" },
     286   [ +  -  +  - ]:        173 :     { "echojson", 8, "arg8" },
     287   [ +  -  +  - ]:        173 :     { "echojson", 9, "arg9" },
     288   [ +  -  +  - ]:        173 :     { "rescanblockchain", 0, "start_height"},
     289   [ +  -  +  - ]:        173 :     { "rescanblockchain", 1, "stop_height"},
     290   [ +  -  +  - ]:        173 :     { "createwallet", 1, "disable_private_keys"},
     291   [ +  -  +  - ]:        173 :     { "createwallet", 2, "blank"},
     292   [ +  -  +  - ]:        173 :     { "createwallet", 4, "avoid_reuse"},
     293   [ +  -  +  - ]:        173 :     { "createwallet", 5, "descriptors"},
     294   [ +  -  +  - ]:        173 :     { "createwallet", 6, "load_on_startup"},
     295   [ +  -  +  - ]:        173 :     { "createwallet", 7, "external_signer"},
     296   [ +  -  +  - ]:        173 :     { "restorewallet", 2, "load_on_startup"},
     297   [ +  -  +  - ]:        173 :     { "loadwallet", 1, "load_on_startup"},
     298   [ +  -  +  - ]:        173 :     { "unloadwallet", 1, "load_on_startup"},
     299   [ +  -  +  - ]:        173 :     { "getnodeaddresses", 0, "count"},
     300   [ +  -  +  - ]:        173 :     { "addpeeraddress", 1, "port"},
     301   [ +  -  +  - ]:        173 :     { "addpeeraddress", 2, "tried"},
     302   [ +  -  +  - ]:        173 :     { "sendmsgtopeer", 0, "peer_id" },
     303   [ +  -  +  - ]:        173 :     { "stop", 0, "wait" },
     304   [ +  -  -  + ]:        173 :     { "addnode", 2, "v2transport" },
     305                 :            : };
     306                 :            : // clang-format on
     307                 :            : 
     308                 :            : /** Parse string to UniValue or throw runtime_error if string contains invalid JSON */
     309                 :       3571 : static UniValue Parse(std::string_view raw)
     310                 :            : {
     311                 :       3571 :     UniValue parsed;
     312   [ +  -  +  +  :       3571 :     if (!parsed.read(raw)) throw std::runtime_error(tfm::format("Error parsing JSON: %s", raw));
          +  -  +  -  -  
                +  -  + ]
     313                 :       2288 :     return parsed;
     314         [ +  - ]:       4854 : }
     315                 :            : 
     316                 :            : class CRPCConvertTable
     317                 :            : {
     318                 :            : private:
     319                 :            :     std::set<std::pair<std::string, int>> members;
     320                 :            :     std::set<std::pair<std::string, std::string>> membersByName;
     321                 :            : 
     322                 :            : public:
     323                 :            :     CRPCConvertTable();
     324                 :            : 
     325                 :            :     /** Return arg_value as UniValue, and first parse it if it is a non-string parameter */
     326                 :      24379 :     UniValue ArgToUniValue(std::string_view arg_value, const std::string& method, int param_idx)
     327                 :            :     {
     328   [ +  -  +  +  :      24379 :         return members.count({method, param_idx}) > 0 ? Parse(arg_value) : arg_value;
             +  +  +  - ]
     329                 :       1265 :     }
     330                 :            : 
     331                 :            :     /** Return arg_value as UniValue, and first parse it if it is a non-string parameter */
     332                 :        410 :     UniValue ArgToUniValue(std::string_view arg_value, const std::string& method, const std::string& param_name)
     333                 :            :     {
     334   [ +  -  +  +  :        410 :         return membersByName.count({method, param_name}) > 0 ? Parse(arg_value) : arg_value;
             +  +  +  - ]
     335                 :         18 :     }
     336                 :            : };
     337                 :            : 
     338                 :        173 : CRPCConvertTable::CRPCConvertTable()
     339                 :            : {
     340         [ +  + ]:      47229 :     for (const auto& cp : vRPCConvertParams) {
     341         [ +  - ]:      47056 :         members.emplace(cp.methodName, cp.paramIdx);
     342         [ +  - ]:      47056 :         membersByName.emplace(cp.methodName, cp.paramName);
     343                 :            :     }
     344                 :        173 : }
     345                 :            : 
     346                 :        173 : static CRPCConvertTable rpcCvtTable;
     347                 :            : 
     348                 :       4995 : UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
     349                 :            : {
     350         [ +  - ]:       6099 :     UniValue params(UniValue::VARR);
     351                 :            : 
     352         [ +  + ]:      27493 :     for (unsigned int idx = 0; idx < strParams.size(); idx++) {
     353                 :      23602 :         std::string_view value{strParams[idx]};
     354   [ +  +  +  - ]:      23602 :         params.push_back(rpcCvtTable.ArgToUniValue(value, strMethod, idx));
     355                 :      22498 :     }
     356                 :            : 
     357                 :       3891 :     return params;
     358         [ +  - ]:       4995 : }
     359                 :            : 
     360                 :        336 : UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<std::string> &strParams)
     361                 :            : {
     362         [ +  - ]:        515 :     UniValue params(UniValue::VOBJ);
     363         [ +  - ]:        336 :     UniValue positional_args{UniValue::VARR};
     364                 :            : 
     365         [ +  + ]:       1344 :     for (std::string_view s: strParams) {
     366                 :       1187 :         size_t pos = s.find('=');
     367         [ +  + ]:       1187 :         if (pos == std::string::npos) {
     368   [ +  -  +  +  :        777 :             positional_args.push_back(rpcCvtTable.ArgToUniValue(s, strMethod, positional_args.size()));
                   +  - ]
     369                 :        616 :             continue;
     370                 :            :         }
     371                 :            : 
     372   [ +  -  +  - ]:        410 :         std::string name{s.substr(0, pos)};
     373         [ +  - ]:        410 :         std::string_view value{s.substr(pos+1)};
     374                 :            : 
     375                 :            :         // Intentionally overwrite earlier named values with later ones as a
     376                 :            :         // convenience for scripts and command line users that want to merge
     377                 :            :         // options.
     378   [ +  -  +  +  :        428 :         params.pushKV(name, rpcCvtTable.ArgToUniValue(value, strMethod, name));
                   -  + ]
     379                 :        410 :     }
     380                 :            : 
     381   [ +  -  +  + ]:        157 :     if (!positional_args.empty()) {
     382                 :            :         // Use pushKVEnd instead of pushKV to avoid overwriting an explicit
     383                 :            :         // "args" value with an implicit one. Let the RPC server handle the
     384                 :            :         // request as given.
     385   [ +  -  +  -  :         39 :         params.pushKVEnd("args", positional_args);
                   -  + ]
     386                 :         39 :     }
     387                 :            : 
     388                 :        157 :     return params;
     389         [ +  - ]:        354 : }

Generated by: LCOV version 1.14