Collect values from the batch and form a simulated `getinfo` reply. */
| 286 | |
| 287 | /** Collect values from the batch and form a simulated `getinfo` reply. */ |
| 288 | UniValue ProcessReply(const UniValue &batch_in) override |
| 289 | { |
| 290 | UniValue result(UniValue::VOBJ); |
| 291 | std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in, 3); |
| 292 | // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on |
| 293 | // getwalletinfo() is allowed to fail in case there is no wallet. |
| 294 | if (!batch[ID_NETWORKINFO]["error"].isNull()) { |
| 295 | return batch[ID_NETWORKINFO]; |
| 296 | } |
| 297 | if (!batch[ID_BLOCKCHAININFO]["error"].isNull()) { |
| 298 | return batch[ID_BLOCKCHAININFO]; |
| 299 | } |
| 300 | result.pushKV("version", batch[ID_NETWORKINFO]["result"]["version"]); |
| 301 | result.pushKV("protocolversion", batch[ID_NETWORKINFO]["result"]["protocolversion"]); |
| 302 | if (!batch[ID_WALLETINFO].isNull()) { |
| 303 | result.pushKV("walletversion", batch[ID_WALLETINFO]["result"]["walletversion"]); |
| 304 | result.pushKV("balance", batch[ID_WALLETINFO]["result"]["balance"]); |
| 305 | } |
| 306 | result.pushKV("blocks", batch[ID_BLOCKCHAININFO]["result"]["blocks"]); |
| 307 | result.pushKV("timeoffset", batch[ID_NETWORKINFO]["result"]["timeoffset"]); |
| 308 | result.pushKV("connections", batch[ID_NETWORKINFO]["result"]["connections"]); |
| 309 | result.pushKV("proxy", batch[ID_NETWORKINFO]["result"]["networks"][0]["proxy"]); |
| 310 | result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]); |
| 311 | result.pushKV("testnet", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"].get_str() == "test")); |
| 312 | if (!batch[ID_WALLETINFO].isNull()) { |
| 313 | result.pushKV("walletversion", batch[ID_WALLETINFO]["result"]["walletversion"]); |
| 314 | result.pushKV("balance", batch[ID_WALLETINFO]["result"]["balance"]); |
| 315 | result.pushKV("keypoololdest", batch[ID_WALLETINFO]["result"]["keypoololdest"]); |
| 316 | result.pushKV("keypoolsize", batch[ID_WALLETINFO]["result"]["keypoolsize"]); |
| 317 | if (!batch[ID_WALLETINFO]["result"]["unlocked_until"].isNull()) { |
| 318 | result.pushKV("unlocked_until", batch[ID_WALLETINFO]["result"]["unlocked_until"]); |
| 319 | } |
| 320 | result.pushKV("paytxfee", batch[ID_WALLETINFO]["result"]["paytxfee"]); |
| 321 | } |
| 322 | result.pushKV("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]); |
| 323 | result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]); |
| 324 | return JSONRPCReplyObj(result, NullUniValue, 1); |
| 325 | } |
| 326 | }; |
| 327 | |
| 328 | /** Process default single requests */ |
no test coverage detected