Skip to content

Commit

Permalink
implement get_known_ephemeral_addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
ec2 committed Sep 16, 2024
1 parent 566616b commit 971d571
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions zcash_client_memory/src/types/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ impl Account {
(current_addr, current_idx) = self.uivk().find_address(current_idx, request)?;
addrs.push((current_addr.clone(), current_idx));
}

addrs
.into_iter()
.filter_map(|(addr, idx)| addr.transparent().map(|taddr| (*taddr, idx)))
Expand Down
26 changes: 24 additions & 2 deletions zcash_client_memory/src/wallet_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use shardtree::store::ShardStore as _;
use std::{
collections::{hash_map::Entry, HashMap},
num::NonZeroU32,
ops::Range,
};
use zcash_keys::keys::UnifiedIncomingViewingKey;
use zip32::fingerprint::SeedFingerprint;
Expand Down Expand Up @@ -644,8 +645,10 @@ impl<P: consensus::Parameters> WalletRead for MemoryWalletDb<P> {
account_id: Self::AccountId,
) -> Result<HashMap<TransparentAddress, Option<TransparentAddressMetadata>>, Self::Error> {
tracing::debug!("get_transparent_receivers");

Ok(HashMap::new())
self.accounts
.get(account_id)
.map(Account::get_transparent_receivers)
.ok_or_else(|| Error::AccountUnknown(account_id))?
}

#[cfg(feature = "transparent-inputs")]
Expand All @@ -658,6 +661,25 @@ impl<P: consensus::Parameters> WalletRead for MemoryWalletDb<P> {
todo!()
}

#[cfg(feature = "transparent-inputs")]
fn get_known_ephemeral_addresses(
&self,
account_id: Self::AccountId,
index_range: Option<Range<u32>>,
) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, Self::Error> {
let ret = self.get_transparent_receivers(account_id)?;
let ret = ret
.into_iter()
.filter_map(|(addr, meta)| meta.map(|m| (addr, m)));
if let Some(range) = index_range {
Ok(ret
.filter(|(_, meta)| range.contains(&meta.address_index().index()))
.collect())
} else {
Ok(ret.collect())
}
}

fn transaction_data_requests(&self) -> Result<Vec<TransactionDataRequest>, Self::Error> {
tracing::debug!("transaction_data_requests");
todo!()
Expand Down

0 comments on commit 971d571

Please sign in to comment.