Skip to content

Commit

Permalink
Check miner tx has a miner input when deserializing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Boog900 committed Jan 5, 2024
1 parent 93e85c5 commit 2b5d7de
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions coins/monero/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_, _>>()?,
})
}
Expand Down

0 comments on commit 2b5d7de

Please sign in to comment.