diff --git a/Cargo.toml b/Cargo.toml index 9744357eb..d32105499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,7 @@ members = [ lto = true panic = 'abort' codegen-units = 1 + +[profile.dev] +debug = true +opt-level = 0 diff --git a/zcash_extensions/src/consensus/transparent.rs b/zcash_extensions/src/consensus/transparent.rs index a4a3ed073..de06781ff 100644 --- a/zcash_extensions/src/consensus/transparent.rs +++ b/zcash_extensions/src/consensus/transparent.rs @@ -75,7 +75,7 @@ impl<'a> demo::Context for Context<'a> { } /// Wire identifier for the dummy network upgrade epoch. -pub const V1_EPOCH_ID: u32 = 0x7473_6554; +pub const NEXT_BRANCH_ID: u32 = 0x7374f403; /// A set of demo TZEs associated with the dummy network upgrade. struct EpochV1; @@ -102,8 +102,9 @@ impl Epoch for EpochV1 { pub fn epoch_for_branch(consensus_branch_id: u32) -> Option>> { // Map from consensus branch IDs to epochs. + let _tmp_branch_id = NEXT_BRANCH_ID; match consensus_branch_id { - V1_EPOCH_ID => Some(Box::new(EpochV1)), + NEXT_BRANCH_ID => Some(Box::new(EpochV1)), _ => None, } } diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index 7c4d33a5f..90399ace1 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -231,6 +231,7 @@ impl Transaction { } else { (vec![], vec![]) }; + let lock_time = reader.read_u32::()?; let expiry_height = if is_overwinter_v3 || is_sapling_v4 || has_tze { reader.read_u32::()? diff --git a/zcash_primitives/src/transaction/sighash.rs b/zcash_primitives/src/transaction/sighash.rs index e4e6bb464..384568493 100644 --- a/zcash_primitives/src/transaction/sighash.rs +++ b/zcash_primitives/src/transaction/sighash.rs @@ -47,6 +47,7 @@ enum SigHashVersion { Sprout, Overwinter, Sapling, + Next, } impl SigHashVersion { @@ -55,7 +56,7 @@ impl SigHashVersion { match tx.version_group_id { OVERWINTER_VERSION_GROUP_ID => SigHashVersion::Overwinter, SAPLING_VERSION_GROUP_ID => SigHashVersion::Sapling, - FUTURE_VERSION_GROUP_ID => SigHashVersion::Sapling, //FIXME + FUTURE_VERSION_GROUP_ID => SigHashVersion::Next, _ => unimplemented!(), } } else { @@ -193,7 +194,7 @@ pub fn signature_hash_data<'a>( ) -> Vec { let sigversion = SigHashVersion::from_tx(tx); match sigversion { - SigHashVersion::Overwinter | SigHashVersion::Sapling => { + SigHashVersion::Overwinter | SigHashVersion::Sapling | SigHashVersion::Next => { let mut personal = [0; 16]; (&mut personal[..12]).copy_from_slice(ZCASH_SIGHASH_PERSONALIZATION_PREFIX); (&mut personal[12..]) @@ -262,11 +263,12 @@ pub fn signature_hash_data<'a>( .unwrap(); h.update(&data); } + SignableInput::Tze { index, precondition, value, - } => { + } if sigversion == SigHashVersion::Next => { let mut data = ZCASH_TZE_SIGNED_INPUT_DOMAIN_SEPARATOR.to_vec(); tx.tze_inputs[index].prevout.write(&mut data).unwrap(); diff --git a/zcash_primitives/src/transaction/tests.rs b/zcash_primitives/src/transaction/tests.rs index 548ed0231..495d22b2c 100644 --- a/zcash_primitives/src/transaction/tests.rs +++ b/zcash_primitives/src/transaction/tests.rs @@ -66,6 +66,36 @@ fn tx_write_rejects_unexpected_binding_sig() { } } +#[test] +fn test_tze_tx_parse() { + let txn_bytes = vec![ + 0xFF, 0xFF, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x52, 0x52, 0x52, 0x52, + 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, + 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x30, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x20, 0xd9, 0x81, 0x80, 0x87, 0xde, 0x72, 0x44, 0xab, 0xc1, 0xb5, 0xfc, + 0xf2, 0x8e, 0x55, 0xe4, 0x2c, 0x7f, 0xf9, 0xc6, 0x78, 0xc0, 0x60, 0x51, 0x81, 0xf3, 0x7a, + 0xc5, 0xd7, 0x41, 0x4a, 0x7b, 0x95, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + + let tx = Transaction::read(&txn_bytes[..]); + + match tx { + Ok(tx) => assert!(!tx.tze_inputs.is_empty()), + + Err(e) => assert!( + false, + format!( + "An error occurred parsing a serialized TZE transaction: {}", + e + ) + ), + } +} + mod data; #[test] fn zip_0143() {