MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / ProcessReply

Method ProcessReply

src/bitcoin-cli.cpp:356–409  ·  view source on GitHub ↗

Collect values from the batch and form a simulated `getinfo` reply. */

Source from the content-addressed store, hash-verified

354
355 /** Collect values from the batch and form a simulated `getinfo` reply. */
356 UniValue ProcessReply(const UniValue &batch_in) override {
357 UniValue result(UniValue::VOBJ);
358 const std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in);
359 // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass
360 // them on; getwalletinfo() and getbalances are allowed to fail if there
361 // is no wallet.
362 if (!batch[ID_NETWORKINFO]["error"].isNull()) {
363 return batch[ID_NETWORKINFO];
364 }
365 if (!batch[ID_BLOCKCHAININFO]["error"].isNull()) {
366 return batch[ID_BLOCKCHAININFO];
367 }
368 result.pushKV("version", batch[ID_NETWORKINFO]["result"]["version"]);
369 result.pushKV("blocks", batch[ID_BLOCKCHAININFO]["result"]["blocks"]);
370 result.pushKV("headers", batch[ID_BLOCKCHAININFO]["result"]["headers"]);
371 result.pushKV(
372 "verificationprogress",
373 batch[ID_BLOCKCHAININFO]["result"]["verificationprogress"]);
374 result.pushKV("timeoffset",
375 batch[ID_NETWORKINFO]["result"]["timeoffset"]);
376
377 UniValue connections(UniValue::VOBJ);
378 connections.pushKV("in",
379 batch[ID_NETWORKINFO]["result"]["connections_in"]);
380 connections.pushKV("out",
381 batch[ID_NETWORKINFO]["result"]["connections_out"]);
382 connections.pushKV("total",
383 batch[ID_NETWORKINFO]["result"]["connections"]);
384 result.pushKV("connections", std::move(connections));
385
386 result.pushKV("proxy",
387 batch[ID_NETWORKINFO]["result"]["networks"][0]["proxy"]);
388 result.pushKV("difficulty",
389 batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
390 result.pushKV("chain",
391 UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"]));
392 if (!batch[ID_WALLETINFO]["result"].isNull()) {
393 result.pushKV("keypoolsize",
394 batch[ID_WALLETINFO]["result"]["keypoolsize"]);
395 if (!batch[ID_WALLETINFO]["result"]["unlocked_until"].isNull()) {
396 result.pushKV("unlocked_until",
397 batch[ID_WALLETINFO]["result"]["unlocked_until"]);
398 }
399 result.pushKV("paytxfee",
400 batch[ID_WALLETINFO]["result"]["paytxfee"]);
401 }
402 if (!batch[ID_BALANCES]["result"].isNull()) {
403 result.pushKV("balance",
404 batch[ID_BALANCES]["result"]["mine"]["trusted"]);
405 }
406 result.pushKV("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]);
407 result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]);
408 return JSONRPCReplyObj(result, NullUniValue, 1);
409 }
410};
411
412/** Process netinfo requests */

Callers 1

CallRPCFunction · 0.45

Calls 5

JSONRPCProcessBatchReplyFunction · 0.85
JSONRPCReplyObjFunction · 0.85
isNullMethod · 0.80
pushKVMethod · 0.80
UniValueClass · 0.70

Tested by

no test coverage detected