| 302 | } |
| 303 | |
| 304 | UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<std::string> &strParams) |
| 305 | { |
| 306 | UniValue params(UniValue::VOBJ); |
| 307 | |
| 308 | for (const std::string &s: strParams) { |
| 309 | size_t pos = s.find('='); |
| 310 | if (pos == std::string::npos) { |
| 311 | throw(std::runtime_error("No '=' in named argument '"+s+"', this needs to be present for every argument (even if it is empty)")); |
| 312 | } |
| 313 | |
| 314 | std::string name = s.substr(0, pos); |
| 315 | std::string value = s.substr(pos+1); |
| 316 | |
| 317 | if (!rpcCvtTable.convert(strMethod, name)) { |
| 318 | // insert string value directly |
| 319 | params.pushKV(name, value); |
| 320 | } else { |
| 321 | // parse string as JSON, insert bool/number/object/etc. value |
| 322 | params.pushKV(name, ParseNonRFCJSONValue(value)); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | return params; |
| 327 | } |