From 2b71121681f8d310420b9303ee69f30c9f910d3e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 2 Dec 2018 19:15:04 +0000 Subject: [PATCH] Return the entire note and recipient address when scanning an output --- zcash_client_backend/src/wallet.rs | 7 +++---- zcash_client_backend/src/welding_rig.rs | 16 ++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/zcash_client_backend/src/wallet.rs b/zcash_client_backend/src/wallet.rs index 4e85eef2d..a20b09f50 100644 --- a/zcash_client_backend/src/wallet.rs +++ b/zcash_client_backend/src/wallet.rs @@ -4,11 +4,10 @@ use pairing::bls12_381::{Bls12, Fr}; use zcash_primitives::{ jubjub::{edwards, PrimeOrder}, + primitives::{Note, PaymentAddress}, transaction::TxId, }; -pub struct EncCiphertextFrag(pub [u8; 52]); - /// A subset of a [`Transaction`] relevant to wallets and light clients. /// /// [`Transaction`]: zcash_primitives::transaction::Transaction @@ -26,7 +25,7 @@ pub struct WalletShieldedOutput { pub index: usize, pub cmu: Fr, pub epk: edwards::Point, - pub enc_ct: EncCiphertextFrag, pub account: usize, - pub value: u64, + pub note: Note, + pub to: PaymentAddress, } diff --git a/zcash_client_backend/src/welding_rig.rs b/zcash_client_backend/src/welding_rig.rs index 73a1666bc..2e6f2b2c2 100644 --- a/zcash_client_backend/src/welding_rig.rs +++ b/zcash_client_backend/src/welding_rig.rs @@ -13,7 +13,7 @@ use zcash_primitives::{ }; use crate::proto::compact_formats::{CompactBlock, CompactOutput}; -use crate::wallet::{EncCiphertextFrag, WalletShieldedOutput, WalletTx}; +use crate::wallet::{WalletShieldedOutput, WalletTx}; /// Scans a [`CompactOutput`] with a set of [`ExtendedFullViewingKey`]s. /// @@ -59,23 +59,19 @@ fn scan_output( tree.append(node).unwrap(); for (account, ivk) in ivks.iter().enumerate() { - let value = match try_sapling_compact_note_decryption(ivk, &epk, &cmu, &ct) { - Some((note, _)) => note.value, + let (note, to) = match try_sapling_compact_note_decryption(ivk, &epk, &cmu, &ct) { + Some(ret) => ret, None => continue, }; - // It's ours, so let's copy the ciphertext fragment and return - let mut enc_ct = EncCiphertextFrag([0u8; 52]); - enc_ct.0.copy_from_slice(&ct); - return Some(( WalletShieldedOutput { index, cmu, epk, - enc_ct, account, - value, + note, + to, }, IncrementalWitness::from_tree(tree), )); @@ -251,7 +247,7 @@ mod tests { assert_eq!(tx.shielded_outputs.len(), 1); assert_eq!(tx.shielded_outputs[0].index, 0); assert_eq!(tx.shielded_outputs[0].account, 0); - assert_eq!(tx.shielded_outputs[0].value, 5); + assert_eq!(tx.shielded_outputs[0].note.value, 5); // Check that the witness root matches assert_eq!(new_witnesses.len(), 1);