Skip to content

Commit

Permalink
zcash_client_backend: Add AccountSource::key_derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Dec 6, 2024
1 parent 2da2b3e commit cc2dfbf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Added
- `zcash_client_backend::data_api::AccountSource::key_derivation`

### Changed
- `zcash_client_backend::data_api::WalletRead`:
- The `create_account`, `import_account_hd`, and `import_account_ufvk`
Expand Down
22 changes: 22 additions & 0 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,28 @@ pub enum AccountSource {
},
}

impl AccountSource {
/// Returns the key derivation metadata for the account source, if any is available.
pub fn key_derivation(&self) -> Option<&Zip32Derivation> {
match self {
AccountSource::Derived { derivation, .. } => Some(derivation),
AccountSource::Imported {
purpose: AccountPurpose::Spending { derivation },
..
} => derivation.as_ref(),
_ => None,
}
}

/// Returns the application-level key source identifier.
pub fn key_source(&self) -> Option<&str> {
match self {
AccountSource::Derived { key_source, .. } => key_source.as_ref().map(|s| s.as_str()),
AccountSource::Imported { key_source, .. } => key_source.as_ref().map(|s| s.as_str()),
}
}
}

/// A set of capabilities that a client account must provide.
pub trait Account {
type AccountId: Copy;
Expand Down

0 comments on commit cc2dfbf

Please sign in to comment.