From 2b5d7defaffa6cd5fbcf0bea903b317a9129121f Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 5 Jan 2024 15:17:53 +0000 Subject: [PATCH] Check miner tx has a miner input when deserializing. --- coins/monero/src/block.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/coins/monero/src/block.rs b/coins/monero/src/block.rs index 2bced983b..895c4e6e1 100644 --- a/coins/monero/src/block.rs +++ b/coins/monero/src/block.rs @@ -114,9 +114,16 @@ impl Block { } pub fn read(r: &mut R) -> io::Result { + 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::>()?, }) }