diff --git a/zcash_client_backend/CHANGELOG.md b/zcash_client_backend/CHANGELOG.md index 3890166d4a..add82033ad 100644 --- a/zcash_client_backend/CHANGELOG.md +++ b/zcash_client_backend/CHANGELOG.md @@ -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`. diff --git a/zcash_client_backend/src/data_api.rs b/zcash_client_backend/src/data_api.rs index 3c959916af..2f11c07893 100644 --- a/zcash_client_backend/src/data_api.rs +++ b/zcash_client_backend/src/data_api.rs @@ -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; @@ -581,13 +584,21 @@ pub trait Account { } #[cfg(any(test, feature = "test-dependencies"))] -impl Account for (A, UnifiedFullViewingKey) { +impl Account for (A, UnifiedFullViewingKey, BlockHeight) { 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, @@ -602,14 +613,10 @@ impl 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 Account for (A, UnifiedIncomingViewingKey) { +impl Account for (A, UnifiedIncomingViewingKey, BlockHeight) { type AccountId = A; fn id(&self) -> A { @@ -620,6 +627,10 @@ impl Account for (A, UnifiedIncomingViewingKey) { None } + fn birthday_height(&self) -> BlockHeight { + self.2 + } + fn source(&self) -> &AccountSource { &AccountSource::Imported { purpose: AccountPurpose::ViewOnly, diff --git a/zcash_client_backend/src/data_api/testing.rs b/zcash_client_backend/src/data_api/testing.rs index 5c643c1ee6..b5b2a48901 100644 --- a/zcash_client_backend/src/data_api/testing.rs +++ b/zcash_client_backend/src/data_api/testing.rs @@ -403,6 +403,10 @@ impl Account for TestAccount { self.account.name() } + fn birthday_height(&self) -> BlockHeight { + self.account.birthday_height() + } + fn source(&self) -> &AccountSource { self.account.source() } @@ -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, Self::Error> { Ok(Vec::new()) diff --git a/zcash_client_memory/src/types/account.rs b/zcash_client_memory/src/types/account.rs index e19712304d..e60a904b62 100644 --- a/zcash_client_memory/src/types/account.rs +++ b/zcash_client_memory/src/types/account.rs @@ -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 } @@ -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 { diff --git a/zcash_client_sqlite/src/wallet.rs b/zcash_client_sqlite/src/wallet.rs index e3f0a27cbd..42490ef47f 100644 --- a/zcash_client_sqlite/src/wallet.rs +++ b/zcash_client_sqlite/src/wallet.rs @@ -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 } @@ -539,7 +543,7 @@ pub(crate) fn add_account( 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()) {