diff options
author | Jon Atack <jon@atack.com> | 2020-08-13 16:29:10 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2020-08-31 16:11:51 +0200 |
commit | 19377b2fd24704bff6c805946575b116f07d5e0d (patch) | |
tree | 7cfc853a0307fcd50719bd2c60bd25175e70dfd6 | |
parent | a3653c159e4f5c887eec9ea608e474eaa299fc07 (diff) | |
download | bitcoin-19377b2fd24704bff6c805946575b116f07d5e0d.tar.xz |
cli: start dashboard report with chain and version header
-rw-r--r-- | src/bitcoin-cli.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 037b5fd06d..a2670ed1a6 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -315,6 +315,12 @@ private: (onion_pos == addr_len - ONION_LEN || onion_pos == addr.find_last_of(":") - ONION_LEN); } bool m_verbose{false}; //!< Whether user requested verbose -netinfo report + std::string ChainToString() const + { + if (gArgs.GetChainName() == CBaseChainParams::TESTNET) return " testnet"; + if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest"; + return ""; + } public: const int ID_PEERINFO = 0; const int ID_NETWORKINFO = 1; @@ -369,7 +375,10 @@ public: } } - std::string result; + // 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())}; + return JSONRPCReplyObj(UniValue{result}, NullUniValue, 1); } }; |