rest: Allow fetching stale header #35909

pull davidgumberg wants to merge 3 commits into bitcoin:master from davidgumberg:2026-08-05-rest-staleheader changing 6 files +134 −28
  1. davidgumberg commented at 10:42 PM on August 5, 2026: contributor

    This is one approach that would resolve #35897.

    Being able to request stale block headers is useful for clients that want to learn the ancestors of a blockhash e.g. when following a re-org up and matches the functionality of the getblockheader RPC.

    This branch takes the approach that a user has to set count=1 and opt-in to non-active-chain blocks with activechainonly=false.

    Alternative approaches:

    Fetching stale blocks when count=1 without a new param

    Hyrum's Law suggests that a client out there relies on the property that /headers/ returns [] for non-active-chain blocks, so this is probably dangerous.

    A separate /header/ interface

    This is nice because it avoids the parameter matrix, and we can have a REST path that matches the semantics of getblockheader, but I am not sure if this is worth the additional implementation complexity, but I could rework towards this approach if others feel strongly.

    Another rest endpoint that supports negative ranges

    e.g. see #33752


    LLM Disclosure: Used as a research tool and rubber ducky while making this PR, but all code and text came from some indeterminate place inside my body.

  2. rest: refactor: Extract bool param parsing logic into a helper. 31e38d8542
  3. rest: /headers/activechainonly=false to allow querying stale blocks. f5c9d8289c
  4. doc: Add release note and usage for activechainonly REST param. bd9d6bc4e9
  5. DrahtBot added the label RPC/REST/ZMQ on Aug 5, 2026
  6. DrahtBot commented at 10:42 PM on August 5, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK jeanpablojp
    Concept ACK sedited

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  7. sedited commented at 6:14 AM on August 6, 2026: contributor

    Concept ACK

  8. jeanpablojp commented at 1:44 AM on August 15, 2026: contributor

    tACK bd9d6bc4e98ae2ded3772127d933294c64b744e0

    On the question in the PR description: I'd stick with the parameter because it solves the issue's use case without opening a new endpoint to maintain, and #33752 never got in.

  9. in doc/release-notes-reststaleheader.md:1 in bd9d6bc4e9
       0 | @@ -0,0 +1,5 @@
       1 | +REST
    


    jeanpablojp commented at 1:44 AM on August 15, 2026:

    shouldn't this be renamed to release-notes-35909.md before merge?


    davidgumberg commented at 2:00 AM on August 15, 2026:

    That is the pattern used in lots of other PR's, and recommended by the developer notes, but I think as long as the release note file is uniquely named it's fine, the instructions in developer-notes.md are to guard against things like release-notes-wallet.md it seems to me.

  10. DrahtBot requested review from sedited on Aug 15, 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-08-31 19:51 UTC

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