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

Method ProcessReply

src/bitcoin-cli.cpp:290–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288 }
289
290 UniValue ProcessReply(const UniValue& reply) override
291 {
292 if (!reply["error"].isNull()) {
293 if (reply["error"]["code"].getInt<int>() == RPC_METHOD_NOT_FOUND) {
294 throw std::runtime_error("-addrinfo requires bitcoind v26.0 or later which supports getaddrmaninfo RPC. Please upgrade your node or use bitcoin-cli from the same version.");
295 }
296 return reply;
297 }
298 // Process getaddrmaninfo reply
299 const std::vector<std::string>& network_types{reply["result"].getKeys()};
300 const std::vector<UniValue>& addrman_counts{reply["result"].getValues()};
301
302 // Prepare result to return to user.
303 UniValue result{UniValue::VOBJ}, addresses{UniValue::VOBJ};
304
305 for (size_t i = 0; i < network_types.size(); ++i) {
306 int addr_count = addrman_counts[i]["total"].getInt<int>();
307 if (network_types[i] == "all_networks") {
308 addresses.pushKV("total", addr_count);
309 } else {
310 addresses.pushKV(network_types[i], addr_count);
311 }
312 }
313 result.pushKV("addresses_known", std::move(addresses));
314 return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V2);
315 }
316};
317
318/** Process getinfo requests */

Callers

nothing calls this directly

Calls 4

JSONRPCReplyObjFunction · 0.85
isNullMethod · 0.80
pushKVMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected