Check miner tx has a miner input when deserializing.

This commit is contained in:
Boog900 2024-01-05 15:17:53 +00:00 committed by Luke Parker
parent f3429ec1ef
commit e7b0ed3e7e

View file

@ -114,9 +114,16 @@ impl Block {
}
pub fn read<R: Read>(r: &mut R) -> io::Result<Block> {
let header = BlockHeader::read(r)?;
let miner_tx = Transaction::read(r)?;
if !matches!(miner_tx.prefix.inputs.as_slice(), &[Input::Gen(_)]) {
Err(io::Error::other("Miner transaction has incorrect input type."))?;
}
Ok(Block {
header: BlockHeader::read(r)?,
miner_tx: Transaction::read(r)?,
header,
miner_tx,
txs: (0_usize .. read_varint(r)?).map(|_| read_bytes(r)).collect::<Result<_, _>>()?,
})
}