Collect values from the batch and form a simulated `getinfo` reply. */
| 322 | |
| 323 | /** Collect values from the batch and form a simulated `getinfo` reply. */ |
| 324 | UniValue ProcessReply(const UniValue &batch_in) override |
| 325 | { |
| 326 | UniValue result(UniValue::VOBJ); |
| 327 | const std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in); |
| 328 | // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on; |
| 329 | // getwalletinfo() and getbalances() are allowed to fail if there is no wallet. |
| 330 | if (!batch[ID_NETWORKINFO]["error"].isNull()) { |
| 331 | return batch[ID_NETWORKINFO]; |
| 332 | } |
| 333 | if (!batch[ID_BLOCKCHAININFO]["error"].isNull()) { |
| 334 | return batch[ID_BLOCKCHAININFO]; |
| 335 | } |
| 336 | result.pushKV("version", batch[ID_NETWORKINFO]["result"]["version"]); |
| 337 | result.pushKV("blocks", batch[ID_BLOCKCHAININFO]["result"]["blocks"]); |
| 338 | result.pushKV("headers", batch[ID_BLOCKCHAININFO]["result"]["headers"]); |
| 339 | result.pushKV("verificationprogress", batch[ID_BLOCKCHAININFO]["result"]["verificationprogress"]); |
| 340 | result.pushKV("timeoffset", batch[ID_NETWORKINFO]["result"]["timeoffset"]); |
| 341 | |
| 342 | UniValue connections(UniValue::VOBJ); |
| 343 | connections.pushKV("in", batch[ID_NETWORKINFO]["result"]["connections_in"]); |
| 344 | connections.pushKV("out", batch[ID_NETWORKINFO]["result"]["connections_out"]); |
| 345 | connections.pushKV("total", batch[ID_NETWORKINFO]["result"]["connections"]); |
| 346 | result.pushKV("connections", connections); |
| 347 | |
| 348 | result.pushKV("networks", batch[ID_NETWORKINFO]["result"]["networks"]); |
| 349 | result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]); |
| 350 | result.pushKV("chain", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"])); |
| 351 | if (!batch[ID_WALLETINFO]["result"].isNull()) { |
| 352 | result.pushKV("has_wallet", true); |
| 353 | result.pushKV("keypoolsize", batch[ID_WALLETINFO]["result"]["keypoolsize"]); |
| 354 | result.pushKV("walletname", batch[ID_WALLETINFO]["result"]["walletname"]); |
| 355 | if (!batch[ID_WALLETINFO]["result"]["unlocked_until"].isNull()) { |
| 356 | result.pushKV("unlocked_until", batch[ID_WALLETINFO]["result"]["unlocked_until"]); |
| 357 | } |
| 358 | result.pushKV("paytxfee", batch[ID_WALLETINFO]["result"]["paytxfee"]); |
| 359 | } |
| 360 | if (!batch[ID_BALANCES]["result"].isNull()) { |
| 361 | result.pushKV("balance", batch[ID_BALANCES]["result"]["mine"]["trusted"]); |
| 362 | } |
| 363 | result.pushKV("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]); |
| 364 | result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]); |
| 365 | return JSONRPCReplyObj(result, NullUniValue, 1); |
| 366 | } |
| 367 | }; |
| 368 | |
| 369 | /** Process netinfo requests */ |
no test coverage detected