Skip to content

Commit 0dbde70

Browse files
committed
rpc: use GetNetworkNames() in getnetworkinfo and getpeerinfo helps
1 parent 1c3af37 commit 0dbde70

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/rpc/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static RPCHelpMan getpeerinfo()
104104
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"},
105105
{RPCResult::Type::STR, "addrbind", "(ip:port) Bind address of the connection to the peer"},
106106
{RPCResult::Type::STR, "addrlocal", "(ip:port) Local address as reported by the peer"},
107-
{RPCResult::Type::STR, "network", "Network (ipv4, ipv6, or onion) the peer connected through"},
107+
{RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/* append_unroutable */ true), ", ") + ")"},
108108
{RPCResult::Type::NUM, "mapped_as", "The AS in the BGP route to the peer used for diversifying\n"
109109
"peer selection (only available if the asmap config flag is set)"},
110110
{RPCResult::Type::STR_HEX, "services", "The services offered"},
@@ -587,7 +587,7 @@ static RPCHelpMan getnetworkinfo()
587587
{
588588
{RPCResult::Type::OBJ, "", "",
589589
{
590-
{RPCResult::Type::STR, "name", "network (ipv4, ipv6 or onion)"},
590+
{RPCResult::Type::STR, "name", "network (" + Join(GetNetworkNames(), ", ") + ")"},
591591
{RPCResult::Type::BOOL, "limited", "is the network limited using -onlynet?"},
592592
{RPCResult::Type::BOOL, "reachable", "is the network reachable?"},
593593
{RPCResult::Type::STR, "proxy", "(\"host:port\") the proxy that is used for this network, or empty if none"},

test/functional/rpc_net.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def test_getpeerinfo(self):
101101
assert_equal(peer_info[1][0]['connection_type'], 'manual')
102102
assert_equal(peer_info[1][1]['connection_type'], 'inbound')
103103

104+
# Check dynamically generated networks list in getpeerinfo help output.
105+
assert "(ipv4, ipv6, onion, not_publicly_routable)" in self.nodes[0].help("getpeerinfo")
106+
104107
def test_getnettotals(self):
105108
self.log.info("Test getnettotals")
106109
# Test getnettotals and getpeerinfo by doing a ping. The bytes
@@ -149,6 +152,9 @@ def test_getnetworkinfo(self):
149152
for info in network_info:
150153
assert_net_servicesnames(int(info["localservices"], 0x10), info["localservicesnames"])
151154

155+
# Check dynamically generated networks list in getnetworkinfo help output.
156+
assert "(ipv4, ipv6, onion)" in self.nodes[0].help("getnetworkinfo")
157+
152158
def test_getaddednodeinfo(self):
153159
self.log.info("Test getaddednodeinfo")
154160
assert_equal(self.nodes[0].getaddednodeinfo(), [])

0 commit comments

Comments
 (0)