MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ProcessReply

Method ProcessReply

src/bitcoin-cli.cpp:340–381  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

338
339 /** Collect values from the batch and form a simulated `getinfo` reply. */
340 UniValue ProcessReply(const UniValue &batch_in) override
341 {
342 UniValue result(UniValue::VOBJ);
343 const std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in);
344 // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on;
345 // getwalletinfo() and getbalances() are allowed to fail if there is no wallet.
346 if (!batch[ID_NETWORKINFO]["error"].isNull()) {
347 return batch[ID_NETWORKINFO];
348 }
349 if (!batch[ID_BLOCKCHAININFO]["error"].isNull()) {
350 return batch[ID_BLOCKCHAININFO];
351 }
352 result.pushKV("version", batch[ID_NETWORKINFO]["result"]["version"]);
353 result.pushKV("blocks", batch[ID_BLOCKCHAININFO]["result"]["blocks"]);
354 result.pushKV("headers", batch[ID_BLOCKCHAININFO]["result"]["headers"]);
355 result.pushKV("verificationprogress", batch[ID_BLOCKCHAININFO]["result"]["verificationprogress"]);
356 result.pushKV("timeoffset", batch[ID_NETWORKINFO]["result"]["timeoffset"]);
357
358 UniValue connections(UniValue::VOBJ);
359 connections.pushKV("in", batch[ID_NETWORKINFO]["result"]["connections_in"]);
360 connections.pushKV("out", batch[ID_NETWORKINFO]["result"]["connections_out"]);
361 connections.pushKV("total", batch[ID_NETWORKINFO]["result"]["connections"]);
362 result.pushKV("connections", std::move(connections));
363
364 result.pushKV("networks", batch[ID_NETWORKINFO]["result"]["networks"]);
365 result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
366 result.pushKV("chain", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"]));
367 if (!batch[ID_WALLETINFO]["result"].isNull()) {
368 result.pushKV("has_wallet", true);
369 result.pushKV("keypoolsize", batch[ID_WALLETINFO]["result"]["keypoolsize"]);
370 result.pushKV("walletname", batch[ID_WALLETINFO]["result"]["walletname"]);
371 if (!batch[ID_WALLETINFO]["result"]["unlocked_until"].isNull()) {
372 result.pushKV("unlocked_until", batch[ID_WALLETINFO]["result"]["unlocked_until"]);
373 }
374 }
375 if (!batch[ID_BALANCES]["result"].isNull()) {
376 result.pushKV("balance", batch[ID_BALANCES]["result"]["mine"]["trusted"]);
377 }
378 result.pushKV("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]);
379 result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]);
380 return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V2);
381 }
382};
383
384/** Process netinfo requests */

Callers 2

CallIPCFunction · 0.45
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