mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 05:29:25 +00:00
Respond to 1.1 A2 (also cited as 2 1)
`read_vec` was unbounded. It now accepts an optional bound. In some places, we are able to define and provide a bound (Bulletproofs(+)' `L` and `R` vectors). In others, we cannot (the amount of inputs within a transaction, which is not subject to any rule in the current consensus other than the total transaction size limit). Usage of `None` in those locations preserves the existing behavior.
This commit is contained in:
@@ -71,7 +71,7 @@ impl Input {
|
||||
let amount = if amount == 0 { None } else { Some(amount) };
|
||||
Input::ToKey {
|
||||
amount,
|
||||
key_offsets: read_vec(read_varint, r)?,
|
||||
key_offsets: read_vec(read_varint, None, r)?,
|
||||
key_image: read_torsion_free_point(r)?,
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ impl TransactionPrefix {
|
||||
pub fn read<R: Read>(r: &mut R, version: u64) -> io::Result<TransactionPrefix> {
|
||||
let additional_timelock = Timelock::read(r)?;
|
||||
|
||||
let inputs = read_vec(|r| Input::read(r), r)?;
|
||||
let inputs = read_vec(|r| Input::read(r), None, r)?;
|
||||
if inputs.is_empty() {
|
||||
Err(io::Error::other("transaction had no inputs"))?;
|
||||
}
|
||||
@@ -250,10 +250,10 @@ impl TransactionPrefix {
|
||||
let mut prefix = TransactionPrefix {
|
||||
additional_timelock,
|
||||
inputs,
|
||||
outputs: read_vec(|r| Output::read((!is_miner_tx) && (version == 2), r), r)?,
|
||||
outputs: read_vec(|r| Output::read((!is_miner_tx) && (version == 2), r), None, r)?,
|
||||
extra: vec![],
|
||||
};
|
||||
prefix.extra = read_vec(read_byte, r)?;
|
||||
prefix.extra = read_vec(read_byte, None, r)?;
|
||||
Ok(prefix)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user