aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-09-16 18:43:42 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-09-16 18:44:20 +0200
commit0de84b732852f7d6db1f5f3f80d985c29a37fbff (patch)
tree4b6a632a54b47c7c16ba2c4815ea7036597c2f9f
parentcdf12c7b3d713e5b92e8631657cb4c666b4d27d4 (diff)
parent49d503aefa74f11e5d93432987fa3775ed82c979 (diff)
downloadbitcoin-0de84b732852f7d6db1f5f3f80d985c29a37fbff.tar.xz
Merge bitcoin/bitcoin#22544: cli -addrinfo: drop torv2; torv3 becomes onion per GetNetworkName()
49d503aefa74f11e5d93432987fa3775ed82c979 doc: update -addrinfo in release-notes.md and tor.md (Jon Atack) 75ea9ecf11bfeb120c58dc6c62539021a94ef97c cli -addrinfo: drop torv2, torv3 becomes onion per GetNetworkName() (Jon Atack) Pull request description: #22050 removed torv2 support from 22.0. For 23.0 and subsequent releases, we can probably remove torv2 from -addrinfo. before ``` "addresses_known": { "ipv4": 58305, "ipv6": 5138, "torv2": 0, "torv3": 5441, "i2p": 14, "total": 68898 } ``` after ``` "addresses_known": { "ipv4": 58305, "ipv6": 5138, "onion": 5441, "i2p": 14, "total": 68898 } ``` Per the naming of `netbase.{h, cpp}::GetNetworkName()`, torv3 becomes onion, which is what is printed in the output of getpeerinfo, getnetworkinfo and getnodeaddresses. ACKs for top commit: practicalswift: cr ACK 49d503aefa74f11e5d93432987fa3775ed82c979 Zero-1729: tACK 49d503aefa74f11e5d93432987fa3775ed82c979 🧉 klementtan: Code review and tested ACK 49d503aefa74f11e5d93432987fa3775ed82c979 Tree-SHA512: bca52520d8b12c26f1c329d661b9e22c567954ed2af7d2a16d7669eae1a221eada20944f8b2f4e78e31a7190d5f3d3fbfd37509e5edf2d9a3747a0a8f4e375bb
-rw-r--r--doc/release-notes.md4
-rw-r--r--doc/tor.md7
-rw-r--r--src/bitcoin-cli.cpp7
3 files changed, 9 insertions, 9 deletions
diff --git a/doc/release-notes.md b/doc/release-notes.md
index 6815408ca7..a8de76c078 100644
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -91,6 +91,10 @@ Tools and Utilities
- Update `-getinfo` to return data in a user-friendly format that also reduces vertical space. (#21832)
+- CLI `-addrinfo` now returns a single field for the number of `onion` addresses
+ known to the node instead of separate `torv2` and `torv3` fields, as support
+ for Tor V2 addresses was removed from Bitcoin Core in 22.0. (#22544)
+
Wallet
------
diff --git a/doc/tor.md b/doc/tor.md
index a3ec1987aa..be35914e02 100644
--- a/doc/tor.md
+++ b/doc/tor.md
@@ -23,10 +23,9 @@ There are several ways to see your local onion address in Bitcoin Core:
You may set the `-debug=tor` config logging option to have additional
information in the debug log about your Tor configuration.
-CLI `-addrinfo` returns the number of addresses known to your node per network
-type, including Tor v2 and v3. This is useful to see how many onion addresses
-are known to your node for `-onlynet=onion` and how many Tor v3 addresses it
-knows when upgrading to Bitcoin Core v22.0 and up that supports Tor v3 only.
+CLI `-addrinfo` returns the number of addresses known to your node per
+network. This can be useful to see how many onion peers your node knows,
+e.g. for `-onlynet=onion`.
## 1. Run Bitcoin Core behind a Tor proxy
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index e75ba81b54..4ccd1f4fee 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -242,7 +242,7 @@ public:
class AddrinfoRequestHandler : public BaseRequestHandler
{
private:
- static constexpr std::array m_networks{"ipv4", "ipv6", "torv2", "torv3", "i2p"};
+ static constexpr std::array m_networks{"ipv4", "ipv6", "onion", "i2p"};
int8_t NetworkStringToId(const std::string& str) const
{
for (size_t i = 0; i < m_networks.size(); ++i) {
@@ -268,13 +268,10 @@ public:
if (!nodes.empty() && nodes.at(0)["network"].isNull()) {
throw std::runtime_error("-addrinfo requires bitcoind server to be running v22.0 and up");
}
- // Count the number of peers we know by network, including torv2 versus torv3.
+ // Count the number of peers known to our node, by network.
std::array<uint64_t, m_networks.size()> counts{{}};
for (const UniValue& node : nodes) {
std::string network_name{node["network"].get_str()};
- if (network_name == "onion") {
- network_name = node["address"].get_str().size() > 22 ? "torv3" : "torv2";
- }
const int8_t network_id{NetworkStringToId(network_name)};
if (network_id == UNKNOWN_NETWORK) continue;
++counts.at(network_id);