This makes the code more consistent between compact proofs and compact blocks, which will make it easier to factorize the code.
Note that this introduce a change in behavior: previously a malformed compact block with overflowing transaction indexes could have its header attached if valid. Now a malformed compact block due to overflowing indexes is detected invalid at deserialization time and the header is not processed. This is not a concern has a malformed compact block is either the result of a malfunctioning node or a malicious one.
A unit test is added to check the index overflow, similar to what is done for the compact proofs. This code is not factorized because it requires to manually build the stream, which makes it difficult to reuse the code.
Depends on D11568.