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:
Luke Parker
2025-07-23 08:58:02 -04:00
parent b426bfcfe8
commit 6b8cf6653a
8 changed files with 43 additions and 30 deletions

View File

@@ -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)
}