aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-cli.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-08-30 12:38:40 +0200
committerJon Atack <jon@atack.com>2020-08-31 16:13:17 +0200
commit644be659abfcf7c638e17795bafedad73bc55b27 (patch)
tree2d32a6df26b3c13c787c24a57e8610ad2a0e2c96 /src/bitcoin-cli.cpp
parentce57bf6cc0cdaf8233fd8a20e0d1c5b69d17d2a3 (diff)
downloadbitcoin-644be659abfcf7c638e17795bafedad73bc55b27.tar.xz
cli: add -netinfo server version check and error message
Diffstat (limited to 'src/bitcoin-cli.cpp')
-rw-r--r--src/bitcoin-cli.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index ad514e7939..f895d90feb 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -373,6 +373,11 @@ public:
if (!batch[ID_PEERINFO]["error"].isNull()) return batch[ID_PEERINFO];
if (!batch[ID_NETWORKINFO]["error"].isNull()) return batch[ID_NETWORKINFO];
+ const UniValue& networkinfo{batch[ID_NETWORKINFO]["result"]};
+ if (networkinfo["version"].get_int() < 209900) {
+ throw std::runtime_error("-netinfo requires bitcoind server to be running v0.21.0 and up");
+ }
+
// Count peer connection totals, and if m_verbose is true, store peer data in a vector of structs.
const int64_t time_now{GetSystemTimeInSeconds()};
int ipv4_i{0}, ipv6_i{0}, onion_i{0}, block_relay_i{0}, total_i{0}; // inbound conn counters
@@ -430,7 +435,6 @@ public:
}
// Generate report header.
- const UniValue& networkinfo{batch[ID_NETWORKINFO]["result"]};
std::string result{strprintf("%s %s%s - %i%s\n\n", PACKAGE_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].get_int(), networkinfo["subversion"].get_str())};
// Report detailed peer connections list sorted by direction and minimum ping time.