rpc: Fix off-by-one error in getblockchaininfo help #34393

pull billymcbip wants to merge 1 commits into bitcoin:master from billymcbip:getblockchaininfo changing 1 files +1 −1
  1. billymcbip commented at 1:46 pm on January 23, 2026: contributor

    Correct the headers field description in getblockchaininfo.

    “The current number of headers we have validated” is wrong - the field reports the height of the best known header.

    I’m open to suggestions regarding the exact wording.

    Sample output:

    0{
    1  "chain": "main",
    2  "blocks": 933527,
    3  "headers": 933527,
    4  ...
    5}
    
  2. rpc: Fix off-by-one error in getblockchaininfo help 76c2a3d799
  3. DrahtBot added the label RPC/REST/ZMQ on Jan 23, 2026
  4. DrahtBot commented at 1:46 pm on January 23, 2026: contributor

    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/34393.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  5. musaHaruna commented at 2:31 pm on February 6, 2026: contributor

    I think the change makes sense. The current help doc says; “The current number of headers we have validated”, which I think it implies; It is a count of headers that have been validated. So a reader would reasonably interpret this as: “Total number of headers validated by the node so far” which sounds like a running total. After checking the implementation: obj.pushKV("headers", chainman.m_best_header ? chainman.m_best_header->nHeight : -1); header returns nHeight (which is the height of the best known header chain tip) this is a single height value — not a count, through m_best_header->nHeight which in its doc states “Best header we’ve seen so far for which the block is not known to be invalid (used, among others, for getheaders queries’ starting points)”. My interpretation is that m_best_header is a pointer to the tip of the highest cumulative-work valid header chain known to the node. Open to feedback from other reviewers if my understanding is inaccurate.

    I think the PR title and commit message could be improved, because the goal of the PR is to correct the documentation. The title should reflect that the headers field description is inaccurate, rather than suggesting an off-by-one error (which implies a value is wrong by exactly +1 or −1).

    As for the wording I think it makes sense. But let’s see what other reviewers think about the change.

  6. billymcbip commented at 5:46 pm on February 6, 2026: contributor

    @musaHaruna, thank you.

    I think the PR title and commit message could be improved … rather than suggesting an off-by-one error (which implies a value is wrong by exactly +1 or −1).

    The number of headers (or blocks) in a chain is height + 1. Since the field reports height, it reports a value that is exactly 1 lower than the number it claims to report.

  7. billymcbip closed this on Feb 9, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-22 00:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me