mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-12 14:09:25 +00:00
Fix deserializing v2 miner transactions
This commit is contained in:
@@ -194,9 +194,17 @@ impl RctBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Read a RctBase.
|
/// Read a RctBase.
|
||||||
pub fn read<R: Read>(inputs: usize, outputs: usize, r: &mut R) -> io::Result<(RctBase, RctType)> {
|
pub fn read<R: Read>(
|
||||||
|
inputs: usize,
|
||||||
|
outputs: usize,
|
||||||
|
r: &mut R,
|
||||||
|
) -> io::Result<Option<(RctType, RctBase)>> {
|
||||||
|
let rct_type = read_byte(r)?;
|
||||||
|
if rct_type == 0 {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
let rct_type =
|
let rct_type =
|
||||||
RctType::try_from(read_byte(r)?).map_err(|()| io::Error::other("invalid RCT type"))?;
|
RctType::try_from(rct_type).map_err(|()| io::Error::other("invalid RCT type"))?;
|
||||||
|
|
||||||
match rct_type {
|
match rct_type {
|
||||||
RctType::AggregateMlsagBorromean | RctType::MlsagBorromean => {}
|
RctType::AggregateMlsagBorromean | RctType::MlsagBorromean => {}
|
||||||
@@ -215,7 +223,8 @@ impl RctBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((
|
Ok(Some((
|
||||||
|
rct_type,
|
||||||
RctBase {
|
RctBase {
|
||||||
fee: read_varint(r)?,
|
fee: read_varint(r)?,
|
||||||
// Only read pseudo_outs if they have yet to be moved to RctPrunable
|
// Only read pseudo_outs if they have yet to be moved to RctPrunable
|
||||||
@@ -232,8 +241,7 @@ impl RctBase {
|
|||||||
.collect::<Result<_, _>>()?,
|
.collect::<Result<_, _>>()?,
|
||||||
commitments: read_raw_vec(read_point, outputs, r)?,
|
commitments: read_raw_vec(read_point, outputs, r)?,
|
||||||
},
|
},
|
||||||
rct_type,
|
)))
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,11 +477,11 @@ impl RctProofs {
|
|||||||
inputs: usize,
|
inputs: usize,
|
||||||
outputs: usize,
|
outputs: usize,
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> io::Result<RctProofs> {
|
) -> io::Result<Option<RctProofs>> {
|
||||||
let base = RctBase::read(inputs, outputs, r)?;
|
let Some((rct_type, base)) = RctBase::read(inputs, outputs, r)? else { return Ok(None) };
|
||||||
Ok(RctProofs {
|
Ok(Some(RctProofs {
|
||||||
base: base.0,
|
base,
|
||||||
prunable: RctPrunable::read(base.1, ring_length, inputs, outputs, r)?,
|
prunable: RctPrunable::read(rct_type, ring_length, inputs, outputs, r)?,
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ impl Transaction {
|
|||||||
|
|
||||||
Ok(Transaction::V1 { prefix, signatures })
|
Ok(Transaction::V1 { prefix, signatures })
|
||||||
} else if version == 2 {
|
} else if version == 2 {
|
||||||
let proofs = Some(RctProofs::read(
|
let proofs = RctProofs::read(
|
||||||
prefix.inputs.first().map_or(0, |input| match input {
|
prefix.inputs.first().map_or(0, |input| match input {
|
||||||
Input::Gen(_) => 0,
|
Input::Gen(_) => 0,
|
||||||
Input::ToKey { key_offsets, .. } => key_offsets.len(),
|
Input::ToKey { key_offsets, .. } => key_offsets.len(),
|
||||||
@@ -403,7 +403,7 @@ impl Transaction {
|
|||||||
prefix.inputs.len(),
|
prefix.inputs.len(),
|
||||||
prefix.outputs.len(),
|
prefix.outputs.len(),
|
||||||
r,
|
r,
|
||||||
)?);
|
)?;
|
||||||
|
|
||||||
Ok(Transaction::V2 { prefix, proofs })
|
Ok(Transaction::V2 { prefix, proofs })
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user