Skip to content

Commit c227100

Browse files
committed
cli: create local addresses, ports, and scores report
1 parent d3f77b7 commit c227100

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/bitcoin-cli.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,17 @@ class NetinfoRequestHandler : public BaseRequestHandler
387387
result += strprintf("out %5i %5i %5i %5i %5i\n", ipv4_o, ipv6_o, onion_o, total_o, block_relay_o);
388388
result += strprintf("total %5i %5i %5i %5i %5i\n", ipv4_i + ipv4_o, ipv6_i + ipv6_o, onion_i + onion_o, total_i + total_o, block_relay_i + block_relay_o);
389389

390+
// Report local addresses, ports, and scores.
391+
result += "\nLocal addresses";
392+
const UniValue& local_addrs{networkinfo["localaddresses"]};
393+
if (local_addrs.empty()) {
394+
result += ": n/a\n";
395+
} else {
396+
for (const UniValue& addr : local_addrs.getValues()) {
397+
result += strprintf("\n%-40i port %5i score %6i", addr["address"].get_str(), addr["port"].get_int(), addr["score"].get_int());
398+
}
399+
}
400+
390401
return JSONRPCReplyObj(UniValue{result}, NullUniValue, 1);
391402
}
392403
};

0 commit comments

Comments
 (0)