Skip to content

RPC: Restore `getblockheader` to allow any chain, plus add test

Calin Culianu requested to merge cculianu/bitcoin-cash-node:issue_178 into master

Summary

MR !443 (merged) introduced a regression whereby getblockheader no longer allowed querying headers for anything but the active chain.

This was raised in issue #178 (closed).

This commit restores the original behavior for getblockheader by undoing the regression introduced there, thus allowing a client to query any header, not just the active chain's headers.

This also brings getblockheader back into symmetric alignment with getblock which always allowed clients to query any block the node knows about, including inactive chain blocks.

A test was also added to test for this regression. It is called bchn-rpc-inactive-chain.py and it will be a place to put additional "inactive-chain-specific" tests in the future -- since this test builds 2 chains and then activates 1 of them, leaving the other inactive.

For now the new test:

  • Tests/guards against the regression we saw with !443 (merged) ever being introduced again.
  • Also guards getblockstats and getchaintxstats from producing results from the inactive chain (these two, unlike getblockheader are supposed to refuse to return info for inactive chains).

Closes issue #178 (closed).

Test Plan

  • ninja check check-functional
Edited by Calin Culianu

Merge request reports