While looking at issue #21351, it turned out that the problem was a lack of tor v3 addresses known to the node. It became clear (e.g. #21351 (comment)) that a CLI command returning the number of addresses the node knows per network (with a tor v2 / v3 breakdown) would be very helpful. This patch adds that.
-addrinfo
is useful to see if your node knows enough addresses in a network to use options like -onlynet=<network>
, or to upgrade to the upcoming tor release that no longer supports tor v2, for which you’ll need to be sure your node knows enough tor v3 peers.
0$ bitcoin-cli --help | grep -A1 addrinfo
1 -addrinfo
2 Get the number of addresses known to the node, per network and total.
3
4$ bitcoin-cli -addrinfo
5{
6 "addresses_known": {
7 "ipv4": 14406,
8 "ipv6": 2511,
9 "torv2": 5563,
10 "torv3": 2842,
11 "i2p": 8,
12 "total": 25330
13 }
14}
15
16$ bitcoin-cli -addrinfo 1
17error: -addrinfo takes no arguments
This can be manually tested, for example, with commands like this:
0$ bitcoin-cli getnodeaddresses 0 | jq '.[] | (select(.address | contains(".onion")) | select(.address | length <= 22)) | .address' | wc -l
15563
2$ bitcoin-cli getnodeaddresses 0 | jq '.[] | (select(.address | contains(".onion")) | select(.address | length > 22)) | .address' | wc -l
32842
4$ bitcoin-cli getnodeaddresses 0 | jq '.[] | .address' | wc -l
525330