30 {
"setmocktime", 0,
"timestamp" },
31 {
"generate", 0,
"nblocks" },
32 {
"generate", 1,
"maxtries" },
33 {
"setgenerate", 0,
"generate" },
34 {
"setgenerate", 1,
"genproclimit" },
35 {
"generatetoaddress", 0,
"nblocks" },
36 {
"generatetoaddress", 2,
"maxtries" },
37 {
"getnetworkhashps", 0,
"nblocks" },
38 {
"getnetworkhashps", 1,
"height" },
39 {
"sendtoaddress", 1,
"amount" },
40 {
"sendtoaddress", 4,
"subtractfeefromamount" },
41 {
"sendtoaddress", 5 ,
"replaceable" },
42 {
"sendtoaddress", 6 ,
"conf_target" },
43 {
"settxfee", 0,
"amount" },
44 {
"sethdseed", 0,
"newkeypool" },
45 {
"getreceivedbyaddress", 1,
"minconf" },
46 {
"getreceivedbylabel", 1,
"minconf" },
47 {
"listreceivedbyaddress", 0,
"minconf" },
48 {
"listreceivedbyaddress", 1,
"include_empty" },
49 {
"listreceivedbyaddress", 2,
"include_watchonly" },
50 {
"listreceivedbylabel", 0,
"minconf" },
51 {
"listreceivedbylabel", 1,
"include_empty" },
52 {
"listreceivedbylabel", 2,
"include_watchonly" },
53 {
"getbalance", 1,
"minconf" },
54 {
"getbalance", 2,
"include_watchonly" },
55 {
"getblockhash", 0,
"height" },
56 {
"waitforblockheight", 0,
"height" },
57 {
"waitforblockheight", 1,
"timeout" },
58 {
"waitforblock", 1,
"timeout" },
59 {
"waitfornewblock", 0,
"timeout" },
60 {
"listtransactions", 1,
"count" },
61 {
"listtransactions", 2,
"skip" },
62 {
"listtransactions", 3,
"include_watchonly" },
63 {
"walletpassphrase", 1,
"timeout" },
64 {
"getblocktemplate", 0,
"template_request" },
65 {
"listsinceblock", 1,
"target_confirmations" },
66 {
"listsinceblock", 2,
"include_watchonly" },
67 {
"listsinceblock", 3,
"include_removed" },
68 {
"sendmany", 1,
"amounts" },
69 {
"sendmany", 2,
"minconf" },
70 {
"sendmany", 4,
"subtractfeefrom" },
71 {
"sendmany", 5 ,
"replaceable" },
72 {
"sendmany", 6 ,
"conf_target" },
73 {
"scantxoutset", 1,
"scanobjects" },
74 {
"addmultisigaddress", 0,
"nrequired" },
75 {
"addmultisigaddress", 1,
"keys" },
76 {
"createmultisig", 0,
"nrequired" },
77 {
"createmultisig", 1,
"keys" },
78 {
"listunspent", 0,
"minconf" },
79 {
"listunspent", 1,
"maxconf" },
80 {
"listunspent", 2,
"addresses" },
81 {
"listunspent", 3,
"include_unsafe" },
82 {
"listunspent", 4,
"query_options" },
83 {
"getblock", 1,
"verbosity" },
84 {
"getblock", 1,
"verbose" },
85 {
"getblockheader", 1,
"verbose" },
86 {
"getchaintxstats", 0,
"nblocks" },
87 {
"gettransaction", 1,
"include_watchonly" },
88 {
"getrawtransaction", 1,
"verbose" },
89 {
"createrawtransaction", 0,
"inputs" },
90 {
"createrawtransaction", 1,
"outputs" },
91 {
"createrawtransaction", 2,
"locktime" },
92 {
"createrawtransaction", 3,
"replaceable" },
93 {
"decoderawtransaction", 1,
"iswitness" },
94 {
"signrawtransaction", 1,
"prevtxs" },
95 {
"signrawtransaction", 2,
"privkeys" },
96 {
"signrawtransactionwithkey", 1,
"privkeys" },
97 {
"signrawtransactionwithkey", 2,
"prevtxs" },
98 {
"signrawtransactionwithwallet", 1,
"prevtxs" },
99 {
"sendrawtransaction", 1,
"allowhighfees" },
100 {
"testmempoolaccept", 0,
"rawtxs" },
101 {
"testmempoolaccept", 1,
"allowhighfees" },
102 {
"combinerawtransaction", 0,
"txs" },
103 {
"fundrawtransaction", 1,
"options" },
104 {
"fundrawtransaction", 2,
"iswitness" },
105 {
"walletcreatefundedpsbt", 0,
"inputs" },
106 {
"walletcreatefundedpsbt", 1,
"outputs" },
107 {
"walletcreatefundedpsbt", 2,
"locktime" },
108 {
"walletcreatefundedpsbt", 3,
"options" },
109 {
"walletcreatefundedpsbt", 4,
"bip32derivs" },
110 {
"walletprocesspsbt", 1,
"sign" },
111 {
"walletprocesspsbt", 3,
"bip32derivs" },
112 {
"createpsbt", 0,
"inputs" },
113 {
"createpsbt", 1,
"outputs" },
114 {
"createpsbt", 2,
"locktime" },
115 {
"createpsbt", 3,
"replaceable" },
116 {
"combinepsbt", 0,
"txs"},
117 {
"finalizepsbt", 1,
"extract"},
118 {
"converttopsbt", 1,
"permitsigdata"},
119 {
"converttopsbt", 2,
"iswitness"},
120 {
"gettxout", 1,
"n" },
121 {
"gettxout", 2,
"include_mempool" },
122 {
"gettxoutproof", 0,
"txids" },
123 {
"lockunspent", 0,
"unlock" },
124 {
"lockunspent", 1,
"transactions" },
125 {
"importprivkey", 2,
"rescan" },
126 {
"importaddress", 2,
"rescan" },
127 {
"importaddress", 3,
"p2sh" },
128 {
"importpubkey", 2,
"rescan" },
129 {
"importmulti", 0,
"requests" },
130 {
"importmulti", 1,
"options" },
131 {
"verifychain", 0,
"checklevel" },
132 {
"verifychain", 1,
"nblocks" },
133 {
"getblockstats", 0,
"hash_or_height" },
134 {
"getblockstats", 1,
"stats" },
135 {
"pruneblockchain", 0,
"height" },
136 {
"keypoolrefill", 0,
"newsize" },
137 {
"getrawmempool", 0,
"verbose" },
138 {
"estimatesmartfee", 0,
"conf_target" },
139 {
"estimaterawfee", 0,
"conf_target" },
140 {
"estimaterawfee", 1,
"threshold" },
141 {
"prioritisetransaction", 1,
"dummy" },
142 {
"prioritisetransaction", 2,
"fee_delta" },
143 {
"setban", 2,
"bantime" },
144 {
"setban", 3,
"absolute" },
145 {
"setnetworkactive", 0,
"state" },
146 {
"getmempoolancestors", 1,
"verbose" },
147 {
"getmempooldescendants", 1,
"verbose" },
148 {
"bumpfee", 1,
"options" },
149 {
"logging", 0,
"include" },
150 {
"logging", 1,
"exclude" },
151 {
"disconnectnode", 1,
"nodeid" },
153 {
"echojson", 0,
"arg0" },
154 {
"echojson", 1,
"arg1" },
155 {
"echojson", 2,
"arg2" },
156 {
"echojson", 3,
"arg3" },
157 {
"echojson", 4,
"arg4" },
158 {
"echojson", 5,
"arg5" },
159 {
"echojson", 6,
"arg6" },
160 {
"echojson", 7,
"arg7" },
161 {
"echojson", 8,
"arg8" },
162 {
"echojson", 9,
"arg9" },
163 {
"rescanblockchain", 0,
"start_height"},
164 {
"rescanblockchain", 1,
"stop_height"},
165 {
"createwallet", 1,
"disable_private_keys"},
166 {
"getnodeaddresses", 0,
"count"},
173 std::set<std::pair<std::string, int>>
members;
179 bool convert(
const std::string& method,
int idx) {
180 return (
members.count(std::make_pair(method, idx)) > 0);
182 bool convert(
const std::string& method,
const std::string&
name) {
189 const unsigned int n_elem =
190 (
sizeof(vRPCConvertParams) /
sizeof(vRPCConvertParams[0]));
192 for (
unsigned int i = 0; i < n_elem; i++) {
193 members.insert(std::make_pair(vRPCConvertParams[i].methodName,
194 vRPCConvertParams[i].paramIdx));
195 membersByName.insert(std::make_pair(vRPCConvertParams[i].methodName,
196 vRPCConvertParams[i].paramName));
208 if (!jVal.
read(std::string(
"[")+strVal+std::string(
"]")) ||
210 throw std::runtime_error(std::string(
"Error parsing JSON:")+strVal);
218 for (
unsigned int idx = 0; idx < strParams.size(); idx++) {
219 const std::string& strVal = strParams[idx];
221 if (!rpcCvtTable.
convert(strMethod, idx)) {
237 for (
const std::string &s: strParams) {
238 size_t pos = s.find(
'=');
239 if (pos == std::string::npos) {
240 throw(std::runtime_error(
"No '=' in named argument '"+s+
"', this needs to be present for every argument (even if it is empty)"));
243 std::string
name = s.substr(0, pos);
244 std::string value = s.substr(pos+1);
bool read(const char *raw, size_t len)
std::set< std::pair< std::string, int > > members
UniValue RPCConvertValues(const std::string &strMethod, const std::vector< std::string > &strParams)
Convert positional arguments to command-specific RPC representation.
bool push_back(const UniValue &val)
UniValue ParseNonRFCJSONValue(const std::string &strVal)
Non-RFC4627 JSON parser, accepts internal values (such as numbers, true, false, null) as well as obje...
bool convert(const std::string &method, const std::string &name)
std::string paramName
parameter name
bool pushKV(const std::string &key, const UniValue &val)
bool convert(const std::string &method, int idx)
std::string methodName
method whose params want conversion
UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector< std::string > &strParams)
Convert named arguments to command-specific RPC representation.
std::set< std::pair< std::string, std::string > > membersByName
int paramIdx
0-based idx of param to convert