mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-01 08:12:14 +00:00
Return the entire note and recipient address when scanning an output
This commit is contained in:
parent
f899ecfce5
commit
2b71121681
@ -4,11 +4,10 @@
|
|||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
jubjub::{edwards, PrimeOrder},
|
jubjub::{edwards, PrimeOrder},
|
||||||
|
primitives::{Note, PaymentAddress},
|
||||||
transaction::TxId,
|
transaction::TxId,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct EncCiphertextFrag(pub [u8; 52]);
|
|
||||||
|
|
||||||
/// A subset of a [`Transaction`] relevant to wallets and light clients.
|
/// A subset of a [`Transaction`] relevant to wallets and light clients.
|
||||||
///
|
///
|
||||||
/// [`Transaction`]: zcash_primitives::transaction::Transaction
|
/// [`Transaction`]: zcash_primitives::transaction::Transaction
|
||||||
@ -26,7 +25,7 @@ pub struct WalletShieldedOutput {
|
|||||||
pub index: usize,
|
pub index: usize,
|
||||||
pub cmu: Fr,
|
pub cmu: Fr,
|
||||||
pub epk: edwards::Point<Bls12, PrimeOrder>,
|
pub epk: edwards::Point<Bls12, PrimeOrder>,
|
||||||
pub enc_ct: EncCiphertextFrag,
|
|
||||||
pub account: usize,
|
pub account: usize,
|
||||||
pub value: u64,
|
pub note: Note<Bls12>,
|
||||||
|
pub to: PaymentAddress<Bls12>,
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ use zcash_primitives::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::proto::compact_formats::{CompactBlock, CompactOutput};
|
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.
|
/// Scans a [`CompactOutput`] with a set of [`ExtendedFullViewingKey`]s.
|
||||||
///
|
///
|
||||||
@ -59,23 +59,19 @@ fn scan_output(
|
|||||||
tree.append(node).unwrap();
|
tree.append(node).unwrap();
|
||||||
|
|
||||||
for (account, ivk) in ivks.iter().enumerate() {
|
for (account, ivk) in ivks.iter().enumerate() {
|
||||||
let value = match try_sapling_compact_note_decryption(ivk, &epk, &cmu, &ct) {
|
let (note, to) = match try_sapling_compact_note_decryption(ivk, &epk, &cmu, &ct) {
|
||||||
Some((note, _)) => note.value,
|
Some(ret) => ret,
|
||||||
None => continue,
|
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((
|
return Some((
|
||||||
WalletShieldedOutput {
|
WalletShieldedOutput {
|
||||||
index,
|
index,
|
||||||
cmu,
|
cmu,
|
||||||
epk,
|
epk,
|
||||||
enc_ct,
|
|
||||||
account,
|
account,
|
||||||
value,
|
note,
|
||||||
|
to,
|
||||||
},
|
},
|
||||||
IncrementalWitness::from_tree(tree),
|
IncrementalWitness::from_tree(tree),
|
||||||
));
|
));
|
||||||
@ -251,7 +247,7 @@ mod tests {
|
|||||||
assert_eq!(tx.shielded_outputs.len(), 1);
|
assert_eq!(tx.shielded_outputs.len(), 1);
|
||||||
assert_eq!(tx.shielded_outputs[0].index, 0);
|
assert_eq!(tx.shielded_outputs[0].index, 0);
|
||||||
assert_eq!(tx.shielded_outputs[0].account, 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
|
// Check that the witness root matches
|
||||||
assert_eq!(new_witnesses.len(), 1);
|
assert_eq!(new_witnesses.len(), 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user