Skip to content

Commit

Permalink
Merge pull request #1026 from nuttycom/wallet/remove_extfvk_api
Browse files Browse the repository at this point in the history
zcash_client_backend: remove `WalletRead::is_valid_account_extfvk`
  • Loading branch information
daira authored Oct 28, 2023
2 parents 113f558 + a0935b5 commit be8daef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 62 deletions.
5 changes: 5 additions & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ and this library adheres to Rust's notion of
- Almost all uses of `Amount` in `zcash_client_backend::zip321` have been replaced
with `NonNegativeAmount`.

### Removed
- `zcash_client_backend::data_api::WalletRead::is_valid_account_extfvk` has been
removed; it was unused in the ECC mobile wallet SDKs and has been superseded by
`get_account_for_ufvk`.

## [0.10.0] - 2023-09-25

### Notable Changes
Expand Down
19 changes: 2 additions & 17 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use zcash_primitives::{
},
Transaction, TxId,
},
zip32::{AccountId, ExtendedFullViewingKey},
zip32::AccountId,
};

use crate::{
Expand Down Expand Up @@ -326,13 +326,6 @@ pub trait WalletRead {
ufvk: &UnifiedFullViewingKey,
) -> Result<Option<AccountId>, Self::Error>;

/// Checks whether the specified extended full viewing key is associated with the account.
fn is_valid_account_extfvk(
&self,
account: AccountId,
extfvk: &ExtendedFullViewingKey,
) -> Result<bool, Self::Error>;

/// Returns the wallet balances and sync status for an account given the specified minimum
/// number of confirmations, or `Ok(None)` if the wallet has no balance data available.
fn get_wallet_summary(
Expand Down Expand Up @@ -950,7 +943,7 @@ pub mod testing {
components::{Amount, OutPoint},
Transaction, TxId,
},
zip32::{AccountId, ExtendedFullViewingKey},
zip32::AccountId,
};

use crate::{
Expand Down Expand Up @@ -1064,14 +1057,6 @@ pub mod testing {
Ok(None)
}

fn is_valid_account_extfvk(
&self,
_account: AccountId,
_extfvk: &ExtendedFullViewingKey,
) -> Result<bool, Self::Error> {
Ok(false)
}

fn get_wallet_summary(
&self,
_min_confirmations: u32,
Expand Down
10 changes: 1 addition & 9 deletions zcash_client_sqlite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use zcash_primitives::{
},
Transaction, TxId,
},
zip32::{AccountId, DiversifierIndex, ExtendedFullViewingKey},
zip32::{AccountId, DiversifierIndex},
};

use zcash_client_backend::{
Expand Down Expand Up @@ -247,14 +247,6 @@ impl<C: Borrow<rusqlite::Connection>, P: consensus::Parameters> WalletRead for W
wallet::get_account_for_ufvk(self.conn.borrow(), &self.params, ufvk)
}

fn is_valid_account_extfvk(
&self,
account: AccountId,
extfvk: &ExtendedFullViewingKey,
) -> Result<bool, Self::Error> {
wallet::is_valid_account_extfvk(self.conn.borrow(), &self.params, account, extfvk)
}

fn get_wallet_summary(
&self,
min_confirmations: u32,
Expand Down
38 changes: 2 additions & 36 deletions zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
//! - `memo` the shielded memo associated with the output, if any.
use incrementalmerkletree::Retention;
use rusqlite::{self, named_params, OptionalExtension, ToSql};
use rusqlite::{self, named_params, OptionalExtension};
use shardtree::ShardTree;
use std::cmp;
use std::collections::{BTreeMap, HashMap};
Expand All @@ -89,10 +89,7 @@ use zcash_primitives::{
memo::{Memo, MemoBytes},
merkle_tree::read_commitment_tree,
transaction::{components::Amount, Transaction, TxId},
zip32::{
sapling::{DiversifiableFullViewingKey, ExtendedFullViewingKey},
AccountId, DiversifierIndex,
},
zip32::{AccountId, DiversifierIndex},
};

use zcash_client_backend::{
Expand Down Expand Up @@ -461,37 +458,6 @@ pub(crate) fn get_account_for_ufvk<P: consensus::Parameters>(
.map_err(SqliteClientError::from)
}

/// Checks whether the specified [`ExtendedFullViewingKey`] is valid and corresponds to the
/// specified account.
///
/// [`ExtendedFullViewingKey`]: zcash_primitives::zip32::ExtendedFullViewingKey
pub(crate) fn is_valid_account_extfvk<P: consensus::Parameters>(
conn: &rusqlite::Connection,
params: &P,
account: AccountId,
extfvk: &ExtendedFullViewingKey,
) -> Result<bool, SqliteClientError> {
conn.prepare("SELECT ufvk FROM accounts WHERE account = ?")?
.query_row([u32::from(account).to_sql()?], |row| {
row.get(0).map(|ufvk_str: String| {
UnifiedFullViewingKey::decode(params, &ufvk_str)
.map_err(SqliteClientError::CorruptedData)
})
})
.optional()
.map_err(SqliteClientError::from)
.and_then(|row| {
if let Some(ufvk) = row {
ufvk.map(|ufvk| {
ufvk.sapling().map(|dfvk| dfvk.to_bytes())
== Some(DiversifiableFullViewingKey::from(extfvk.clone()).to_bytes())
})
} else {
Ok(false)
}
})
}

pub(crate) trait ScanProgress {
fn sapling_scan_progress(
&self,
Expand Down

0 comments on commit be8daef

Please sign in to comment.