13 #include <boost/algorithm/string/case_conv.hpp> 32 {
"setmocktime", 0,
"timestamp" },
33 {
"generate", 0,
"nblocks" },
34 {
"generate", 1,
"maxtries" },
35 {
"generatetoaddress", 0,
"nblocks" },
36 {
"generatetoaddress", 2,
"maxtries" },
37 {
"getnetworkhashps", 0,
"nblocks" },
38 {
"getnetworkhashps", 1,
"height" },
39 {
"getblocksubsidy", 0,
"height" },
40 {
"sendtoaddress", 1,
"amount" },
41 {
"sendtoaddress", 4,
"subtractfeefromamount" },
42 {
"sendtoaddress", 5 ,
"replaceable" },
43 {
"sendtoaddress", 6 ,
"conf_target" },
44 {
"sendtoaddress", 9,
"changeToSender"},
45 {
"settxfee", 0,
"amount" },
46 {
"getsubsidy", 0,
"height" },
47 {
"getreceivedbyaddress", 1,
"minconf" },
48 {
"getreceivedbyaccount", 1,
"minconf" },
49 {
"listreceivedbyaddress", 0,
"minconf" },
50 {
"listreceivedbyaddress", 1,
"include_empty" },
51 {
"listreceivedbyaddress", 2,
"include_watchonly" },
52 {
"listreceivedbyaccount", 0,
"minconf" },
53 {
"listreceivedbyaccount", 1,
"include_empty" },
54 {
"listreceivedbyaccount", 2,
"include_watchonly" },
55 {
"getbalance", 1,
"minconf" },
56 {
"getbalance", 2,
"include_watchonly" },
57 {
"getblockhash", 0,
"height" },
58 {
"waitforblockheight", 0,
"height" },
59 {
"waitforblockheight", 1,
"timeout" },
60 {
"waitforblock", 1,
"timeout" },
61 {
"waitfornewblock", 0,
"timeout" },
62 {
"move", 2,
"amount" },
63 {
"move", 3,
"minconf" },
64 {
"sendfrom", 2,
"amount" },
65 {
"sendfrom", 3,
"minconf" },
66 {
"listtransactions", 1,
"count" },
67 {
"listtransactions", 2,
"skip" },
68 {
"listtransactions", 3,
"include_watchonly" },
69 {
"listaccounts", 0,
"minconf" },
70 {
"listaccounts", 1,
"include_watchonly" },
71 {
"walletpassphrase", 1,
"timeout" },
72 {
"walletpassphrase", 2,
"stakingonly" },
73 {
"getblocktemplate", 0,
"template_request" },
74 {
"listsinceblock", 1,
"target_confirmations" },
75 {
"listsinceblock", 2,
"include_watchonly" },
76 {
"listsinceblock", 3,
"include_removed" },
77 {
"sendmany", 1,
"amounts" },
78 {
"sendmany", 2,
"minconf" },
79 {
"sendmany", 4,
"subtractfeefrom" },
80 {
"sendmany", 5 ,
"replaceable" },
81 {
"sendmany", 6 ,
"conf_target" },
82 {
"sendmanywithdupes", 1,
"amounts" },
83 {
"sendmanywithdupes", 2,
"minconf" },
84 {
"sendmanywithdupes", 4,
"subtractfeefrom" },
85 {
"addmultisigaddress", 0,
"nrequired" },
86 {
"addmultisigaddress", 1,
"keys" },
88 {
"getaddresstxids", 0,
"addresses"},
89 {
"getaddressmempool", 0,
"addresses"},
90 {
"getaddressdeltas", 0,
"addresses"},
91 {
"getaddressbalance", 0,
"addresses"},
92 {
"getaddressutxos", 0,
"addresses"},
93 {
"getblockhashes", 0,
"high"},
94 {
"getblockhashes", 1,
"low"},
95 {
"getblockhashes", 2,
"options"},
96 {
"getspentinfo", 0,
"argument"},
97 {
"searchlogs", 0,
"fromBlock"},
98 {
"searchlogs", 1,
"toBlock"},
99 {
"searchlogs", 2,
"address"},
100 {
"searchlogs", 3,
"topics"},
101 {
"waitforlogs", 0,
"fromBlock"},
102 {
"waitforlogs", 1,
"txlimit"},
103 {
"waitforlogs", 2,
"address"},
104 {
"waitforlogs", 3,
"topics"},
106 {
"createmultisig", 0,
"nrequired" },
107 {
"createmultisig", 1,
"keys" },
108 {
"listunspent", 0,
"minconf" },
109 {
"listunspent", 1,
"maxconf" },
110 {
"listunspent", 2,
"addresses" },
111 {
"listunspent", 3,
"include_unsafe" },
112 {
"listunspent", 4,
"query_options" },
113 {
"getblock", 1,
"verbosity" },
114 {
"getblock", 1,
"verbose" },
115 {
"getblock", 2,
"legacy" },
116 {
"getblock", 3,
"no_contract" },
117 {
"getblockheader", 1,
"verbose" },
118 {
"getblockheader", 2,
"legacy" },
119 {
"getblockheader", 3,
"no_contract" },
120 {
"getchaintxstats", 0,
"nblocks" },
121 {
"gettransaction", 1,
"include_watchonly" },
122 {
"gettransaction", 2,
"waitconf" },
123 {
"getrawtransaction", 1,
"verbose" },
124 {
"createrawtransaction", 0,
"inputs" },
125 {
"createrawtransaction", 1,
"outputs" },
126 {
"createrawtransaction", 2,
"locktime" },
127 {
"createrawtransaction", 3,
"replaceable" },
128 {
"signrawtransaction", 1,
"prevtxs" },
129 {
"signrawtransaction", 2,
"privkeys" },
130 {
"sendrawtransaction", 1,
"allowhighfees" },
131 {
"combinerawtransaction", 0,
"txs" },
132 {
"fundrawtransaction", 1,
"options" },
133 {
"gettxout", 1,
"n" },
134 {
"gettxout", 2,
"include_mempool" },
135 {
"gettxoutproof", 0,
"txids" },
136 {
"lockunspent", 0,
"unlock" },
137 {
"lockunspent", 1,
"transactions" },
138 {
"importprivkey", 2,
"rescan" },
139 {
"importaddress", 2,
"rescan" },
140 {
"importaddress", 3,
"p2sh" },
141 {
"importpubkey", 2,
"rescan" },
142 {
"importmulti", 0,
"requests" },
143 {
"importmulti", 1,
"options" },
144 {
"verifychain", 0,
"checklevel" },
145 {
"verifychain", 1,
"nblocks" },
146 {
"pruneblockchain", 0,
"height" },
147 {
"keypoolrefill", 0,
"newsize" },
148 {
"getrawmempool", 0,
"verbose" },
149 {
"estimatefee", 0,
"nblocks" },
150 {
"estimatepriority", 0,
"nblocks" },
151 {
"estimatesmartpriority", 0,
"nblocks" },
152 {
"estimatesmartfee", 0,
"conf_target" },
153 {
"estimaterawfee", 0,
"conf_target" },
154 {
"estimaterawfee", 1,
"threshold" },
155 {
"prioritisetransaction", 1,
"dummy" },
156 {
"prioritisetransaction", 2,
"fee_delta" },
157 {
"setban", 2,
"bantime" },
158 {
"setban", 3,
"absolute" },
159 {
"setnetworkactive", 0,
"state" },
160 {
"getmempoolancestors", 1,
"verbose" },
161 {
"getmempooldescendants", 1,
"verbose" },
162 {
"bumpfee", 1,
"options" },
163 {
"logging", 0,
"include" },
164 {
"logging", 1,
"exclude" },
165 {
"disconnectnode", 1,
"nodeid" },
166 {
"callcontract", 3,
"gasLimit" },
167 {
"createcontract", 1,
"gasLimit" },
168 {
"createcontract", 2,
"gasPrice" },
169 {
"createcontract", 4,
"broadcast" },
170 {
"createcontract", 5,
"changeToSender" },
171 {
"sendtocontract", 2,
"amount" },
172 {
"sendtocontract", 3,
"gasLimit" },
173 {
"sendtocontract", 4,
"gasPrice" },
174 {
"sendtocontract", 6,
"broadcast" },
175 {
"sendtocontract", 7,
"changeToSender" },
176 {
"reservebalance", 0,
"reserve"},
177 {
"reservebalance", 1,
"amount"},
178 {
"listcontracts", 0,
"start" },
179 {
"listcontracts", 1,
"maxDisplay" },
180 {
"getstorage", 2,
"index" },
181 {
"getstorage", 1,
"blockNum" },
182 {
"logging", 0,
"include" },
183 {
"logging", 1,
"exclude" },
184 {
"disconnectnode", 1,
"nodeid" },
186 {
"echojson", 0,
"arg0" },
187 {
"echojson", 1,
"arg1" },
188 {
"echojson", 2,
"arg2" },
189 {
"echojson", 3,
"arg3" },
190 {
"echojson", 4,
"arg4" },
191 {
"echojson", 5,
"arg5" },
192 {
"echojson", 6,
"arg6" },
193 {
"echojson", 7,
"arg7" },
194 {
"echojson", 8,
"arg8" },
195 {
"echojson", 9,
"arg9" },
196 {
"setgenerate", 0,
"generate"},
197 {
"setgenerate", 1,
"genproclimit" },
198 {
"getgenerate", 0,
"generate"},
204 std::set<std::pair<std::string, int>>
members;
210 bool convert(
const std::string& method,
int idx) {
211 return (members.count(std::make_pair(method, idx)) > 0);
213 bool convert(
const std::string& method,
const std::string&
name) {
214 return (membersByName.count(std::make_pair(method, name)) > 0);
220 const unsigned int n_elem =
221 (
sizeof(vRPCConvertParams) /
sizeof(vRPCConvertParams[0]));
223 for (
unsigned int i = 0; i < n_elem; i++) {
224 members.insert(std::make_pair(vRPCConvertParams[i].
methodName,
226 membersByName.insert(std::make_pair(vRPCConvertParams[i].methodName,
239 if (!jVal.
read(std::string(
"[")+strVal+std::string(
"]")) ||
241 throw std::runtime_error(std::string(
"Error parsing JSON:")+strVal);
249 for (
unsigned int idx = 0; idx < strParams.size(); idx++) {
250 const std::string& strVal = strParams[idx];
252 if (!rpcCvtTable.
convert(strMethod, idx)) {
268 for (
const std::string &s: strParams) {
269 size_t pos = s.find(
"=");
270 if (pos == std::string::npos) {
271 throw(std::runtime_error(
"No '=' in named argument '"+s+
"', this needs to be present for every argument (even if it is empty)"));
274 std::string
name = s.substr(0, pos);
275 std::string value = s.substr(pos+1);
277 if (!rpcCvtTable.
convert(strMethod, name)) {
279 params.
pushKV(name, value);
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