Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykoren committed Oct 8, 2024
1 parent a0a7d38 commit b2d7b18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions zcash_primitives/src/transaction/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub enum Error<FE> {
/// The builder was constructed with a target height before NU5 activation, but an Orchard
/// spend or output was added.
OrchardBundleNotAvailable,
/// The issuance bundle not initialized.
/// The issuance bundle not initialized.
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
IssuanceBuilderNotAvailable,
/// An error occurred in constructing the Issuance bundle.
Expand Down Expand Up @@ -1461,8 +1461,8 @@ mod tests {
.init_issuance_bundle::<FeeError>(iak, asset.clone(), None)
.unwrap();

let binding = builder.mock_build_no_fee(OsRng).unwrap().into_transaction();
let bundle = binding.issue_bundle().unwrap();
let tx = builder.mock_build_no_fee(OsRng).unwrap().into_transaction();
let bundle = tx.issue_bundle().unwrap();

assert_eq!(bundle.actions().len(), 1, "There should be only one action");
let action = bundle.get_action(asset).unwrap();
Expand Down
19 changes: 14 additions & 5 deletions zcash_primitives/src/transaction/components/issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ fn read_action<R: Read>(mut reader: R) -> io::Result<IssueAction> {
let asset_descr: String = String::from_utf8(asset_descr_bytes)
.map_err(|_| Error::new(ErrorKind::InvalidData, "Asset Description not valid UTF-8"))?;
let notes = Vector::read(&mut reader, |r| read_note(r))?;
let finalize = reader.read_u8()? != 0;
let finalize = match reader.read_u8()? {
0 => false,
1 => true,
_ => {
return Err(Error::new(
ErrorKind::InvalidData,
"Invalid value for finalize",
))
}
};
Ok(IssueAction::from_parts(asset_descr, notes, finalize))
}

Expand Down Expand Up @@ -113,7 +122,7 @@ pub fn write_v6_bundle<W: Write>(
) -> io::Result<()> {
if let Some(bundle) = bundle {
Vector::write_nonempty(&mut writer, bundle.actions(), |w, action| {
write_action(action, w)
write_action(w, action)
})?;
writer.write_all(&bundle.ik().to_bytes())?;
writer.write_all(&<[u8; 64]>::from(bundle.authorization().signature()))?;
Expand All @@ -123,16 +132,16 @@ pub fn write_v6_bundle<W: Write>(
Ok(())
}

fn write_action<W: Write>(action: &IssueAction, mut writer: W) -> io::Result<()> {
fn write_action<W: Write>(mut writer: &mut W, action: &IssueAction) -> io::Result<()> {
Vector::write(&mut writer, action.asset_desc().as_bytes(), |w, b| {
w.write_u8(*b)
})?;
Vector::write(&mut writer, action.notes(), |w, note| write_note(note, w))?;
Vector::write(&mut writer, action.notes(), write_note)?;
writer.write_u8(action.is_finalized() as u8)?;
Ok(())
}

pub fn write_note<W: Write>(note: &Note, writer: &mut W) -> io::Result<()> {
pub fn write_note<W: Write>(writer: &mut W, note: &Note) -> io::Result<()> {
writer.write_all(&note.recipient().to_raw_address_bytes())?;
writer.write_u64::<LittleEndian>(note.value().inner())?;
writer.write_all(&note.asset().to_bytes())?;
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/transaction/components/orchard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<W: Write> WriteBurn<W> for OrchardZSA {
}
}

/// Writes an [`orchard::Bundle`] in the v6 transaction format.
/// Writes an [`orchard::Bundle`] in the appropriate transaction format.
pub fn write_orchard_bundle<W: Write, D: OrchardDomainCommon + WriteBurn<W>>(
bundle: Option<&orchard::Bundle<Authorized, Amount, D>>,
mut writer: W,
Expand Down

0 comments on commit b2d7b18

Please sign in to comment.