mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-22 02:34:55 +00:00
Check miner tx has a miner input when deserializing.
This commit is contained in:
parent
f3429ec1ef
commit
e7b0ed3e7e
1 changed files with 9 additions and 2 deletions
|
@ -114,9 +114,16 @@ impl Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<R: Read>(r: &mut R) -> io::Result<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 {
|
Ok(Block {
|
||||||
header: BlockHeader::read(r)?,
|
header,
|
||||||
miner_tx: Transaction::read(r)?,
|
miner_tx,
|
||||||
txs: (0_usize .. read_varint(r)?).map(|_| read_bytes(r)).collect::<Result<_, _>>()?,
|
txs: (0_usize .. read_varint(r)?).map(|_| read_bytes(r)).collect::<Result<_, _>>()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue