diff --git a/zebra-chain/src/transaction.rs b/zebra-chain/src/transaction.rs index 0376592c..c4a12635 100644 --- a/zebra-chain/src/transaction.rs +++ b/zebra-chain/src/transaction.rs @@ -13,7 +13,7 @@ mod tests; pub use hash::TransactionHash; pub use joinsplit::{JoinSplit, JoinSplitData}; -pub use shielded_data::{OutputDescription, ShieldedData, SpendDescription}; +pub use shielded_data::{Output, ShieldedData, Spend}; pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput}; use crate::proofs::{Bctv14Proof, Groth16Proof}; diff --git a/zebra-chain/src/transaction/serialize.rs b/zebra-chain/src/transaction/serialize.rs index 914fdf77..b63865f3 100644 --- a/zebra-chain/src/transaction/serialize.rs +++ b/zebra-chain/src/transaction/serialize.rs @@ -302,7 +302,7 @@ impl ZcashDeserialize for Option> { } } -impl ZcashSerialize for SpendDescription { +impl ZcashSerialize for Spend { fn zcash_serialize(&self, mut writer: W) -> Result<(), io::Error> { writer.write_all(&self.cv[..])?; writer.write_all(&self.anchor.0[..])?; @@ -314,10 +314,10 @@ impl ZcashSerialize for SpendDescription { } } -impl ZcashDeserialize for SpendDescription { +impl ZcashDeserialize for Spend { fn zcash_deserialize(mut reader: R) -> Result { use crate::note_commitment_tree::SaplingNoteTreeRootHash; - Ok(SpendDescription { + Ok(Spend { cv: reader.read_32_bytes()?, anchor: SaplingNoteTreeRootHash(reader.read_32_bytes()?), nullifier: reader.read_32_bytes()?, @@ -328,7 +328,7 @@ impl ZcashDeserialize for SpendDescription { } } -impl ZcashSerialize for OutputDescription { +impl ZcashSerialize for Output { fn zcash_serialize(&self, mut writer: W) -> Result<(), io::Error> { writer.write_all(&self.cv[..])?; writer.write_all(&self.cmu[..])?; @@ -340,9 +340,9 @@ impl ZcashSerialize for OutputDescription { } } -impl ZcashDeserialize for OutputDescription { +impl ZcashDeserialize for Output { fn zcash_deserialize(mut reader: R) -> Result { - Ok(OutputDescription { + Ok(Output { cv: reader.read_32_bytes()?, cmu: reader.read_32_bytes()?, ephemeral_key: reader.read_32_bytes()?, diff --git a/zebra-chain/src/transaction/shielded_data.rs b/zebra-chain/src/transaction/shielded_data.rs index b3397cfe..fcaed938 100644 --- a/zebra-chain/src/transaction/shielded_data.rs +++ b/zebra-chain/src/transaction/shielded_data.rs @@ -18,7 +18,7 @@ use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize} /// /// [ps]: https://zips.z.cash/protocol/protocol.pdf#spendencoding #[derive(Clone, Debug, PartialEq, Eq)] -pub struct SpendDescription { +pub struct Spend { /// A value commitment to the value of the input note. /// /// XXX refine to a specific type. @@ -38,7 +38,7 @@ pub struct SpendDescription { } #[cfg(test)] -impl Arbitrary for SpendDescription { +impl Arbitrary for Spend { type Parameters = (); fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { @@ -77,7 +77,7 @@ impl Arbitrary for SpendDescription { /// [ps]: https://zips.z.cash/protocol/protocol.pdf#outputencoding #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(test, derive(Arbitrary))] -pub struct OutputDescription { +pub struct Output { /// A value commitment to the value of the input note. /// /// XXX refine to a specific type. @@ -109,25 +109,25 @@ pub struct ShieldedData { /// However, it's not necessary to access or process `first` and `rest` /// separately, as the [`ShieldedData::spends`] and [`ShieldedData::outputs`] /// methods provide iterators over all of the [`SpendDescription`]s and - /// [`OutputDescription`]s. - pub first: Either, - /// The rest of the [`SpendDescription`]s for this transaction. + /// [`Output`]s. + pub first: Either, + /// The rest of the [`Spend`]s for this transaction. /// /// Note that the [`ShieldedData::spends`] method provides an iterator /// over all spend descriptions. - pub rest_spends: Vec, - /// The rest of the [`OutputDescription`]s for this transaction. + pub rest_spends: Vec, + /// The rest of the [`Output`]s for this transaction. /// /// Note that the [`ShieldedData::outputs`] method provides an iterator /// over all output descriptions. - pub rest_outputs: Vec, + pub rest_outputs: Vec, /// A signature on the transaction hash. pub binding_sig: redjubjub::Signature, } impl ShieldedData { - /// Iterate over the [`SpendDescription`]s for this transaction. - pub fn spends(&self) -> impl Iterator { + /// Iterate over the [`Spend`]s for this transaction. + pub fn spends(&self) -> impl Iterator { match self.first { Either::Left(ref spend) => Some(spend), Either::Right(_) => None, @@ -136,8 +136,8 @@ impl ShieldedData { .chain(self.rest_spends.iter()) } - /// Iterate over the [`OutputDescription`]s for this transaction. - pub fn outputs(&self) -> impl Iterator { + /// Iterate over the [`Output`]s for this transaction. + pub fn outputs(&self) -> impl Iterator { match self.first { Either::Left(_) => None, Either::Right(ref output) => Some(output), @@ -179,11 +179,11 @@ impl Arbitrary for ShieldedData { fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { ( prop_oneof![ - any::().prop_map(Either::Left), - any::().prop_map(Either::Right) + any::().prop_map(Either::Left), + any::().prop_map(Either::Right) ], - vec(any::(), 0..10), - vec(any::(), 0..10), + vec(any::(), 0..10), + vec(any::(), 0..10), vec(any::(), 64), ) .prop_map(|(first, rest_spends, rest_outputs, sig_bytes)| {