diff --git a/zebra-chain/src/lib.rs b/zebra-chain/src/lib.rs index 4faaeab7..3c9e5b30 100644 --- a/zebra-chain/src/lib.rs +++ b/zebra-chain/src/lib.rs @@ -36,7 +36,6 @@ pub mod shutdown; pub mod sprout; pub mod subtree; pub mod transaction; -pub mod transparent; pub mod value_balance; pub mod work; diff --git a/zebra-chain/src/primitives/zcash_primitives.rs b/zebra-chain/src/primitives/zcash_primitives.rs index 564afab0..fe3c3d9a 100644 --- a/zebra-chain/src/primitives/zcash_primitives.rs +++ b/zebra-chain/src/primitives/zcash_primitives.rs @@ -10,7 +10,6 @@ use crate::{ parameters::{Network, NetworkUpgrade}, serialization::ZcashSerialize, transaction::{AuthDigest, HashType, SigHash, Transaction}, - transparent::{self, Script}, }; // TODO: move copied and modified code to a separate module. @@ -22,64 +21,18 @@ struct TransparentAuth<'a> { all_prev_outputs: &'a [transparent::Output], } -impl zp_tx::components::transparent::Authorization for TransparentAuth<'_> { - type ScriptSig = zcash_primitives::legacy::Script; -} // In this block we convert our Output to a librustzcash to TxOut. // (We could do the serialize/deserialize route but it's simple enough to convert manually) -impl zp_tx::sighash::TransparentAuthorizingContext for TransparentAuth<'_> { - fn input_amounts(&self) -> Vec { - self.all_prev_outputs - .iter() - .map(|prevout| { - zp_tx::components::amount::Amount::from_nonnegative_i64_le_bytes( - prevout.value.to_bytes(), - ) - .expect("will not fail since it was previously validated") - }) - .collect() - } - - fn input_scriptpubkeys(&self) -> Vec { - self.all_prev_outputs - .iter() - .map(|prevout| { - zcash_primitives::legacy::Script(prevout.lock_script.as_raw_bytes().into()) - }) - .collect() - } -} // Boilerplate mostly copied from `zcash/src/rust/src/transaction_ffi.rs` which is required // to compute sighash. // TODO: remove/change if they improve the API to not require this. -struct MapTransparent<'a> { - auth: TransparentAuth<'a>, -} +// struct MapTransparent<'a> { +// auth: TransparentAuth<'a>, +// } -impl<'a> - zp_tx::components::transparent::MapAuth< - zp_tx::components::transparent::Authorized, - TransparentAuth<'a>, - > for MapTransparent<'a> -{ - fn map_script_sig( - &self, - s: ::ScriptSig, - ) -> ::ScriptSig { - s - } - - fn map_authorization( - &self, - _: zp_tx::components::transparent::Authorized, - ) -> TransparentAuth<'a> { - // TODO: This map should consume self, so we can move self.auth - self.auth.clone() - } -} struct IdentityMap; @@ -189,29 +142,8 @@ pub(crate) fn convert_tx_to_librustzcash( } /// Convert a Zebra transparent::Output into a librustzcash one. -impl TryFrom<&transparent::Output> for zp_tx::components::TxOut { - type Error = io::Error; - - #[allow(clippy::unwrap_in_result)] - fn try_from(output: &transparent::Output) -> Result { - let serialized_output_bytes = output - .zcash_serialize_to_vec() - .expect("zcash_primitives and Zebra transparent output formats must be compatible"); - - zp_tx::components::TxOut::read(&mut serialized_output_bytes.as_slice()) - } -} /// Convert a Zebra transparent::Output into a librustzcash one. -impl TryFrom for zp_tx::components::TxOut { - type Error = io::Error; - - // The borrow is actually needed to use TryFrom<&transparent::Output> - #[allow(clippy::needless_borrow)] - fn try_from(output: transparent::Output) -> Result { - (&output).try_into() - } -} /// Convert a Zebra Amount into a librustzcash one. impl TryFrom> for zp_tx::components::Amount { @@ -223,20 +155,8 @@ impl TryFrom> for zp_tx::components::Amount { } /// Convert a Zebra Script into a librustzcash one. -impl From<&Script> for zcash_primitives::legacy::Script { - fn from(script: &Script) -> Self { - zcash_primitives::legacy::Script(script.as_raw_bytes().to_vec()) - } -} /// Convert a Zebra Script into a librustzcash one. -impl From