diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ab296f7..3f245ade0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ and this project adheres to Rust's notion of - `ValueCommitTrapdoor::to_bytes` - `impl Clone for orchard::tree::MerklePath` +### Changed +- `orchard::builder::Builder::add_output` now takes a `[u8; 512]` for its + `memo` argument instead of an optional value. + ## [0.10.0] - 2024-10-02 ### Changed diff --git a/src/builder.rs b/src/builder.rs index de05aa7de..7592ca108 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -321,17 +321,13 @@ impl OutputInfo { ovk: Option, recipient: Address, value: NoteValue, - memo: Option<[u8; 512]>, + memo: [u8; 512], ) -> Self { Self { ovk, recipient, value, - memo: memo.unwrap_or_else(|| { - let mut memo = [0; 512]; - memo[0] = 0xf6; - memo - }), + memo, } } @@ -342,7 +338,7 @@ impl OutputInfo { let fvk: FullViewingKey = (&SpendingKey::random(rng)).into(); let recipient = fvk.address_at(0u32, Scope::External); - Self::new(None, recipient, NoteValue::zero(), None) + Self::new(None, recipient, NoteValue::zero(), [0u8; 512]) } /// Builds the output half of an action. @@ -578,7 +574,7 @@ impl Builder { ovk: Option, recipient: Address, value: NoteValue, - memo: Option<[u8; 512]>, + memo: [u8; 512], ) -> Result<(), OutputError> { let flags = self.bundle_type.flags(); if !flags.outputs_enabled() { @@ -1171,7 +1167,7 @@ pub mod testing { let ovk = fvk.to_ovk(scope); builder - .add_output(Some(ovk.clone()), addr, value, None) + .add_output(Some(ovk.clone()), addr, value, [0u8; 512]) .unwrap(); } @@ -1284,7 +1280,7 @@ mod tests { ); builder - .add_output(None, recipient, NoteValue::from_raw(5000), None) + .add_output(None, recipient, NoteValue::from_raw(5000), [0u8; 512]) .unwrap(); let balance: i64 = builder.value_balance().unwrap(); assert_eq!(balance, -5000); diff --git a/src/pczt.rs b/src/pczt.rs index 7e079d5b4..0c63ed3ac 100644 --- a/src/pczt.rs +++ b/src/pczt.rs @@ -320,7 +320,7 @@ mod tests { EMPTY_ROOTS[MERKLE_DEPTH_ORCHARD].into(), ); builder - .add_output(None, recipient, NoteValue::from_raw(5000), None) + .add_output(None, recipient, NoteValue::from_raw(5000), [0u8; 512]) .unwrap(); let balance: i64 = builder.value_balance().unwrap(); assert_eq!(balance, -5000); @@ -389,14 +389,14 @@ mod tests { let mut builder = Builder::new(BundleType::DEFAULT, anchor); builder.add_spend(fvk.clone(), note, merkle_path).unwrap(); builder - .add_output(None, recipient, NoteValue::from_raw(10_000), None) + .add_output(None, recipient, NoteValue::from_raw(10_000), [0u8; 512]) .unwrap(); builder .add_output( Some(fvk.to_ovk(Scope::Internal)), fvk.address_at(0u32, Scope::Internal), NoteValue::from_raw(5_000), - None, + [0u8; 512], ) .unwrap(); let balance: i64 = builder.value_balance().unwrap(); diff --git a/tests/builder.rs b/tests/builder.rs index 8ce67e92a..c703cb4b9 100644 --- a/tests/builder.rs +++ b/tests/builder.rs @@ -51,7 +51,7 @@ fn bundle_chain() { ); let note_value = NoteValue::from_raw(5000); assert_eq!( - builder.add_output(None, recipient, note_value, None), + builder.add_output(None, recipient, note_value, [0u8; 512]), Ok(()) ); let (unauthorized, bundle_meta) = builder.build(&mut rng).unwrap().unwrap(); @@ -106,7 +106,7 @@ fn bundle_chain() { let mut builder = Builder::new(BundleType::DEFAULT, anchor); assert_eq!(builder.add_spend(fvk, note, merkle_path), Ok(())); assert_eq!( - builder.add_output(None, recipient, NoteValue::from_raw(5000), None), + builder.add_output(None, recipient, NoteValue::from_raw(5000), [0u8; 512]), Ok(()) ); let (unauthorized, _) = builder.build(&mut rng).unwrap().unwrap();