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