Return the entire note and recipient address when scanning an output

This commit is contained in:
Jack Grigg
2018-12-02 19:15:04 +00:00
parent c3a30b9597
commit 8b353b3d55
2 changed files with 9 additions and 14 deletions

View File

@@ -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);