Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ workspace.
input selection avoids pools incompatible with the requested transaction
version.
- `input_selection::InputSelector::propose_transaction` trait method.
- Trait `Account` has added method `birthday_height`
- `zcash_client_backend::fees`:
- The associated type `ChangeStrategy::MetaSource` is now bounded on the newly
added `MetaSource` type instead of `zcash_client_backend::data_api::InputSource`.
Expand Down
23 changes: 17 additions & 6 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ pub trait Account {
/// Returns the human-readable name for the account, if any has been configured.
fn name(&self) -> Option<&str>;

/// Returns the birthday height for the account.
fn birthday_height(&self) -> BlockHeight;

/// Returns whether this account is derived or imported, and the derivation parameters
/// if applicable.
fn source(&self) -> &AccountSource;
Expand Down Expand Up @@ -581,13 +584,21 @@ pub trait Account {
}

#[cfg(any(test, feature = "test-dependencies"))]
impl<A: Copy> Account for (A, UnifiedFullViewingKey) {
impl<A: Copy> Account for (A, UnifiedFullViewingKey, BlockHeight) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does deserve a wrapper struct?

type AccountId = A;

fn id(&self) -> A {
self.0
}

fn name(&self) -> Option<&str> {
None
}

fn birthday_height(&self) -> BlockHeight {
self.2
}

fn source(&self) -> &AccountSource {
&AccountSource::Imported {
purpose: AccountPurpose::ViewOnly,
Expand All @@ -602,14 +613,10 @@ impl<A: Copy> Account for (A, UnifiedFullViewingKey) {
fn uivk(&self) -> UnifiedIncomingViewingKey {
self.1.to_unified_incoming_viewing_key()
}

fn name(&self) -> Option<&str> {
None
}
}

#[cfg(any(test, feature = "test-dependencies"))]
impl<A: Copy> Account for (A, UnifiedIncomingViewingKey) {
impl<A: Copy> Account for (A, UnifiedIncomingViewingKey, BlockHeight) {
type AccountId = A;

fn id(&self) -> A {
Expand All @@ -620,6 +627,10 @@ impl<A: Copy> Account for (A, UnifiedIncomingViewingKey) {
None
}

fn birthday_height(&self) -> BlockHeight {
self.2
}

fn source(&self) -> &AccountSource {
&AccountSource::Imported {
purpose: AccountPurpose::ViewOnly,
Expand Down
6 changes: 5 additions & 1 deletion zcash_client_backend/src/data_api/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ impl<A: Account> Account for TestAccount<A> {
self.account.name()
}

fn birthday_height(&self) -> BlockHeight {
self.account.birthday_height()
}

fn source(&self) -> &AccountSource {
self.account.source()
}
Expand Down Expand Up @@ -2635,7 +2639,7 @@ impl InputSource for MockWalletDb {
impl WalletRead for MockWalletDb {
type Error = ();
type AccountId = u32;
type Account = (Self::AccountId, UnifiedFullViewingKey);
type Account = (Self::AccountId, UnifiedFullViewingKey, BlockHeight);

fn get_account_ids(&self) -> Result<Vec<Self::AccountId>, Self::Error> {
Ok(Vec::new())
Expand Down
12 changes: 8 additions & 4 deletions zcash_client_memory/src/types/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ impl zcash_client_backend::data_api::Account for Account {
self.account_id
}

fn name(&self) -> Option<&str> {
None
}

fn birthday_height(&self) -> zcash_protocol::consensus::BlockHeight {
self.birthday().height()
}

fn source(&self) -> &AccountSource {
&self.kind
}
Expand All @@ -534,10 +542,6 @@ impl zcash_client_backend::data_api::Account for Account {
fn uivk(&self) -> UnifiedIncomingViewingKey {
self.viewing_key.to_unified_incoming_viewing_key()
}

fn name(&self) -> Option<&str> {
todo!()
}
}

mod serialization {
Expand Down
6 changes: 5 additions & 1 deletion zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ impl zcash_client_backend::data_api::Account for Account {
self.name.as_deref()
}

fn birthday_height(&self) -> BlockHeight {
self.birthday()
}

fn source(&self) -> &AccountSource {
&self.kind
}
Expand Down Expand Up @@ -539,7 +543,7 @@ pub(crate) fn add_account<P: consensus::Parameters>(
birthday: birthday.height(),
};

// If a birthday frontiers are available and the birthday height is less than or equal to the
// If birthday frontiers are available and the birthday height is less than or equal to the
// max-scanned height, insert them into the note commitment trees. Otherwise, we don't need to
// do anything.
if block_max_scanned(conn, params)?.is_some_and(|m| m.block_height() > birthday.height()) {
Expand Down
Loading