Note that we can't call .serialize() directly in
the .calc_sha256() method, as this could wrongly lead
to the serialization of the derived class (CBlock) if
called from an instance there.
This is a partial backport of core#32868
https://github.com/bitcoin/bitcoin/pull/32868/commits/f3c791d2e39133f33b04ebf790c307b0f63bb578
Depends on D18733