diff --git a/rusk-wallet/src/wallet.rs b/rusk-wallet/src/wallet.rs index 56e6dfc2d2..4a2c6756a7 100644 --- a/rusk-wallet/src/wallet.rs +++ b/rusk-wallet/src/wallet.rs @@ -356,15 +356,21 @@ impl Wallet { } let index = addr.index()?; - let notes: Vec = state + let notes: Vec = state .fetch_notes(addr.pk())? .into_iter() - .map(|data| data.note) + .map(|data| NoteLeaf { + note: data.note, + block_height: data.height, + }) .collect(); let seed = self.store.get_seed(); - Ok(phoenix_balance(&derive_phoenix_vk(seed, index), notes)) + Ok(phoenix_balance( + &derive_phoenix_vk(seed, index), + notes.into_iter(), + )) } /// Creates a new public address. @@ -679,7 +685,7 @@ impl Wallet { let tx = state.prove_and_propagate(withdraw); sender_sk.zeroize(); - stake_sk.zerorize(); + stake_sk.zeroize(); tx } diff --git a/wallet-core/tests/notes.rs b/wallet-core/tests/notes.rs index dc0b0c75ba..c7cff81fa5 100644 --- a/wallet-core/tests/notes.rs +++ b/wallet-core/tests/notes.rs @@ -73,7 +73,7 @@ fn test_map_owned() { PhoenixPublicKey::from(&PhoenixSecretKey::random(&mut rng)); let value = 42; - let note_leaves = vec![ + let note_leaves: Vec = vec![ gen_note(&mut rng, true, &owner_1_pks[0], value), // owner 1 gen_note(&mut rng, true, &owner_1_pks[1], value), // owner 1 gen_note(&mut rng, true, &owner_2_pks[0], value), // owner 2 @@ -82,6 +82,14 @@ fn test_map_owned() { gen_note(&mut rng, true, &owner_3_pk, value), // owner 3 ]; + let note_leaves: Vec = note_leaves + .into_iter() + .map(|note| NoteLeaf { + note, + block_height: 0, + }) + .collect(); + // notes with idx 0, 1 and 4 are owned by owner_1 let notes_by_1 = map_owned(&owner_1_sks, ¬e_leaves); assert_eq!(notes_by_1.len(), 3); @@ -143,6 +151,14 @@ fn test_balance() { spendable: 34, }; + let notes: Vec = notes + .into_iter() + .map(|note| NoteLeaf { + note, + block_height: 0, + }) + .collect(); + assert_eq!( phoenix_balance(&(&owner_sk).into(), notes.iter()), expected_balance