Skip to content

Conversation

@stratospher
Copy link
Contributor

@stratospher stratospher commented Jan 29, 2023

Rework of -addrinfo CLI is done using getaddrmaninfo RPC proposed in #27511. This would be useful for users who want to know the total number of addresses the node knows about and can make connections to.

Currently, -addrinfo returns total number of addresses the node knows about after filtering them for quality + recency using isTerrible. However isTerribleaddresses don't matter when selecting outbound peers to connect to. Total number of addresses the node knows about could be higher than what -addrinfo currently displays. See #24370.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 29, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/26988.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK pablomartin4btc
Concept ACK mzumsande, brunoerg
Approach ACK jonatack, sipa
Stale ACK amitiuttarwar, vasild

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • [JSONRPCRequestObj("getaddrmaninfo", NullUniValue, 1)] in src/bitcoin-cli.cpp

2025-12-13

Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK, will review soon.

@amitiuttarwar
Copy link
Contributor

obvious concept ack considering I proposed #26907

Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, only minor nits.

ping @jonatack, could you have a look, especially at the changes to bitcoin-cli?

@fanquake fanquake changed the title [rpc]: Add test-only RPC addrmaninfo for new/tried table address count rpc: Add test-only RPC addrmaninfo for new/tried table address count Feb 7, 2023
@stratospher stratospher changed the title rpc: Add test-only RPC addrmaninfo for new/tried table address count rpc: Add test-only RPC getaddrmaninfo for new/tried table address count Feb 22, 2023
Copy link
Contributor

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@brunoerg
Copy link
Contributor

brunoerg commented Feb 22, 2023

"network" : "str",    (string) The network (ipv4, ipv6, onion, i2p, cjdns)

Instead of being a string, wouldn't make sense it to be an array? E.g. I want to get new/tried table address count for ipv4 and ipv6 together.

@stratospher
Copy link
Contributor Author

Instead of being a string, wouldn't make sense it to be an array? E.g. I want to get new/tried table address count for ipv5 and ipv6 together.

i'm confused about this since making it into RPCArg::Type::ARR would make the RPC harder to type and use?
$ bitcoin-cli getaddrmaninfo "[\"ipv4\", \"ipv6\"]"

and there are only few network types. would be interested in what others think.

@amitiuttarwar
Copy link
Contributor

to minimize the complexity that we need to maintain over time, we try to reduce the amount of client-side niftiness that we offer. it seems to me that the string would offer all the information needed for a client to write a simple query if they wanted the sum of multiple. agreed that the syntax is another challenge of the array type

so I am +1 to leaving as is

@brunoerg
Copy link
Contributor

brunoerg commented Mar 9, 2023

that was just a question, thinking about complexity I agree on leaving it as is.

going to review in depth soon.

@amitiuttarwar
Copy link
Contributor

light code review ACK 7c34c35b47. tested that the RPC and cli endpoints make sense & handle errors reasonably. these changes will require release notes, which can be done here or in a separate PR.

@stratospher
Copy link
Contributor Author

thank you for the reviews! I've pushed an update changing the long key names.
also retained the original key name in -addrinfo's result (addresses_known) in case some other scripts/tools rely on it.

$ build/bin/bitcoin-cli -addrinfo
{
  "addresses_known": {
    "ipv4": 52037,
    "ipv6": 8855,
    "onion": 3465,
    "i2p": 0,
    "cjdns": 0,
    "total": 64357
  },
  "addresses_filtered": {
    "ipv4": 41811,
    "ipv6": 5808,
    "onion": 2465,
    "i2p": 0,
    "cjdns": 0,
    "total": 50084
  }
}

regarding #26988 (comment):

25.x, 26.x and 27.x are all end-of-life; so that seems out of scope for needing to test / accomodate code-wise?

Good point. Thinking of changing it in the next push.

According to bitnodes.io - among bitcoin core nodes, 95% are already on v26+ and therefore support getaddrmaninfo (introduced 2 years ago).

Maybe the concern regarding older node <-> newer CLI compatibility isn't there anymore considering how much the network/software has changed! (cc @jonatack, curious to hear your thoughts and anyone else's of course)

  • 95% of bitcoin core nodes are on v26+ and have access to getaddrmaninfo (introduced 2 years ago)
  • the nodes we're concerned about breaking user space (v22 - v26 nodes) with have reached EOL

@jonatack
Copy link
Member

CLI calls can be made to a node running a different, older version. If a researcher, data gatherer, developer, or node operator is calling this on a pre-getaddrmaninfo node, then the call should still work. As commented above, colleagues here requested that -netinfo continue to work in such cases, and we patched it. There doesn't seem to be any reason not to do the same here, rather than choosing to break it.

uint64_t total{0}; // Total address count
for (size_t i = 1; i < NETWORKS.size() - 1; ++i) {
addresses.pushKV(NETWORKS[i], counts.at(i));
total += counts.at(i);
}
addresses.pushKV("total", total);
result.pushKV("addresses_known", std::move(addresses));
result.pushKV("addresses_filtered", std::move(addresses));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with preferably keeping the field names short, but the data corresponding to "addresses_known" should not change.

Perhaps use "addresses_unfiltered" or "addresses_not_filtered_for_quality_and_recency" for the new field.

As this is a CLI output, as opposed to an RPC one, its output presentation can be more optimized for human use (see -getinfo, for instance) while providing consistent historical data.

@fanquake
Copy link
Member

fanquake commented Nov 20, 2025

CLI calls can be made to a node running a different, older version. If a researcher, data gatherer, developer, or node operator is calling this on a pre-getaddrmaninfo node,

Could you elaborate on why these people, particularly the developers, or node operators, are running EOL versions of Core (with known CVEs); and why they can't upgrade their nodes, but at the same time, they are downloading and using the latest version of bitcoin-cli?

There doesn't seem to be any reason not to do the same here, rather than choosing to break it.

The reason to not do it, is that it then implies we are still supporting versions of our software, which we have marked as EOL.

Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI calls can be made to a node running a different, older version. If a researcher, data gatherer, developer, or node operator is calling this on a pre-getaddrmaninfo node, then the call should still work. As commented above, colleagues here requested that -netinfo continue to work in such cases, and we patched it. There doesn't seem to be any reason not to do the same here, rather than choosing to break it.

I don't agree with that. I don't see bitcoin-cli and bitcoind as completely separate programs that should be supported in arbitrary combinations for eternity.

If that was the case, it would have been a bad mistake to ever have added non-trivial functionality like -addrinfo or -netinfo to bitcoin-cli instead of bitcoind in the first place because that would have created an infinite obligation to maintain compatibility of current bitcoind versions with ancient versions of bitcoin-cli long out of support.

While it makes some limited sense to try to keep up compatibility over version ranges supported at the same time (although even that is debatable in my opinion), I don't think that it is reasonable to make any efforts supporting compatibility beyond this.

currently -addrinfo returns addresses known to the node after
filtering for quality and recency. However, the node considers
all known addresses (even the filtered out addresses) when
selecting peers to connect to.

So update -addrinfo to also display the full set of known
addresses for more useful node information.
@stratospher
Copy link
Contributor Author

I pushed an update. I also don't think we should implement a fallback to support a rare usecase for few individuals. I've run into a few occasions where I used older bitcoind and newer cli but it's when I misconfigure something accidentally and wasn't the behaviour I intended. I guess this is what most normal users would run into.

This is why I think we shouldn't implement a fallback:

  1. since -addrinfo is meant to be a human facing CLI dashboard (as implied in the documentation everywhere) and not an RPC endpoint (which other software/tools use programatically), the human facing CLI dashboard does not require a deprecation path (unlike RPCs). Humans can read and respond to it. It's not meant to used in automated scripts (those should use RPCs directly) and only meant to be read by humans.
  2. if different versions of bitcoind and bitcoin-cli are used - it's the responsibility of the user to do proper package management. bitcoind and bitcoin-cli are versioned and released together.
  3. This feels like an edge case for very few individuals. The transition period is over and 95% of bitcoin core nodes are already on v26+. If someone is capable of downloading the latest bitcoin-cli, they can upgrade their node/use an older bitcoin-cli.
  4. getaddrmaninfo support is there for 95% of bitcoin core nodes that are already on v26+
  5. v22-v27 are all EOL with known security vulnerabilities (from this comment)
  6. it would be contradictory to state in the release notes that we are maintaining compatibility solely for EOL versions only for the human facing CLI dashboard, when we do not maintain EOL support anywhere else.

So my preferred solution is to give human node operators a clear + helpful message explaining the issue and asking them to use an older CLI or newer bitcoind to which they can choose. A clear message is more helpful than silently falling back.

@jonatack, thank you for your feedback and I'm sorry there's a difference in opinion + this is dragging out so long.
I hope the reasons stated here and the comments (1 and 2) above make sense to you. I appreciate your time spent discussing this, and I hope the reasoning above contributes to finding the best long-term solution!

@sipa
Copy link
Member

sipa commented Dec 8, 2025

Concept/Approach ACK. I think it's fine to break compatibility with unmaintained node versions, given that there is a good error message for this case.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 5b05a9959f1633bfee78d9edb180c672b0640ab5

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 5b05a9959f1633bfee78d9edb180c672b0640ab5

with bitcoind < v26:

/build/bin/bitcoin-cli -signet -datadir=/tmp/btc -addrinfo
error: -addrinfo requires bitcoind v26.0 or later which supports getaddrmaninfo RPC. Please upgrade your node or use bitcoin-cli from the same version.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 325f98bca07c3a0c48a46dc18f67376d44c5341d

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 325f98bca07c3a0c48a46dc18f67376d44c5341d

(Left a small suggestion since the older node may be operated by someone other than the CLI user, and upgrading it might not be possible or appropriate when this change is the only reason. I think this would also align with @jonatack’s earlier note.)

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK b3046cc

@DrahtBot DrahtBot requested a review from vasild December 13, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.