From 4489ab526add168daf36684eb3d86957ff3388c1 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Sun, 16 Feb 2025 11:25:43 -0600 Subject: [PATCH] netinfo: return local services in the default report Credit to l0rinc for refactoring ServicesList(). Co-authored-by: l0rinc Co-authored-by: Daniela Brozzoni --- src/bitcoin-cli.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 14a0cb245fa..1f4b512f420 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -463,6 +463,17 @@ private: } return str; } + static std::string ServicesList(const UniValue& services) + { + std::string str{services.size() ? services[0].get_str() : ""}; + for (size_t i{1}; i < services.size(); ++i) { + str += ", " + services[i].get_str(); + } + for (auto& c: str) { + c = (c == '_' ? ' ' : ToLower(c)); + } + return str; + } public: static constexpr int ID_PEERINFO = 0; @@ -636,7 +647,8 @@ public: } } - // Report local addresses, ports, and scores. + // Report local services, addresses, ports, and scores. + result += strprintf("\n\nLocal services: %s", ServicesList(networkinfo["localservicesnames"])); result += "\n\nLocal addresses"; const std::vector& local_addrs{networkinfo["localaddresses"].getValues()}; if (local_addrs.empty()) {