Skip to content

Commit 19377b2

Browse files
committed
cli: start dashboard report with chain and version header
1 parent a3653c1 commit 19377b2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/bitcoin-cli.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ class NetinfoRequestHandler : public BaseRequestHandler
315315
(onion_pos == addr_len - ONION_LEN || onion_pos == addr.find_last_of(":") - ONION_LEN);
316316
}
317317
bool m_verbose{false}; //!< Whether user requested verbose -netinfo report
318+
std::string ChainToString() const
319+
{
320+
if (gArgs.GetChainName() == CBaseChainParams::TESTNET) return " testnet";
321+
if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest";
322+
return "";
323+
}
318324
public:
319325
const int ID_PEERINFO = 0;
320326
const int ID_NETWORKINFO = 1;
@@ -369,7 +375,10 @@ class NetinfoRequestHandler : public BaseRequestHandler
369375
}
370376
}
371377

372-
std::string result;
378+
// Generate report header.
379+
const UniValue& networkinfo{batch[ID_NETWORKINFO]["result"]};
380+
std::string result{strprintf("%s %s%s - %i%s\n\n", PACKAGE_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].get_int(), networkinfo["subversion"].get_str())};
381+
373382
return JSONRPCReplyObj(UniValue{result}, NullUniValue, 1);
374383
}
375384
};

0 commit comments

Comments
 (0)