| 240 | } |
| 241 | |
| 242 | UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<std::string> &strParams) |
| 243 | { |
| 244 | UniValue params(UniValue::VOBJ); |
| 245 | |
| 246 | for (const std::string &s: strParams) { |
| 247 | size_t pos = s.find('='); |
| 248 | if (pos == std::string::npos) { |
| 249 | throw(std::runtime_error("No '=' in named argument '"+s+"', this needs to be present for every argument (even if it is empty)")); |
| 250 | } |
| 251 | |
| 252 | std::string name = s.substr(0, pos); |
| 253 | std::string value = s.substr(pos+1); |
| 254 | |
| 255 | if (!rpcCvtTable.convert(strMethod, name)) { |
| 256 | // insert string value directly |
| 257 | params.pushKV(name, value); |
| 258 | } else { |
| 259 | // parse string as JSON, insert bool/number/object/etc. value |
| 260 | params.pushKV(name, ParseNonRFCJSONValue(value)); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return params; |
| 265 | } |
no test coverage detected