To extend libconsensus’ functionality, I propose to add bitcoinconsensus_verify_header()
the partial checks CheckBlockHeader()
and ContextualCheckBlockHeader
could be exposed as well.
Unlike VerifyScript, VerifyBlockHeader depends on the nodes storage, as it requires data from the blockchain previous to the header being verified. How to exactly interface that data with VerifyBlockHeader can be a delicate matter and it should be of course open to discussion. Here there’s just one proposal.
The offending dependency is CBlockIndex in chain.o, specially CBlockIndex::pprev which is a pointer to another object. All the other dependencies unacceptable for libconsensus have been removed first, to make things easier for someone who wants to propose to solve that final problem in some other way.
Dependencies: -MOVEONLY: Move most consensus function declarations to consensus/consensus.h #6048 -Consensus: Refactor: Consensus version of CheckBlockHeader() #6035 -Separate CValidationState from main #5669 -Chainparams: Refactor: Decouple IsSuperMajority from Params() #5968 -Consensus: Decouple ContextualCheckBlockHeader from checkpoints #5975 -Consensus: Turn CBlockIndex::GetMedianTimePast into independent function #6009 -Consensus: Consensus version of pow functions #6037