Skip to content

Commit

Permalink
Apply some of the simpler fixes from PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Mar 7, 2024
1 parent 6079fe5 commit 72506c6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ pub trait WalletRead {
type AccountId: Copy + Debug + Eq + Hash;

/// Gets some of the account details (e.g. seed fingerprint+index and/or uvk) for a given account id.
///
/// Returns `Ok(None)` if no account by the given ID is known.
fn get_account(&self, account_id: Self::AccountId) -> Result<Option<Account>, Self::Error>;

Expand Down Expand Up @@ -1107,6 +1108,8 @@ pub trait WalletWrite: WalletRead {
/// funds have been received by the currently-available account (in order to enable automated
/// account recovery).
///
/// Panics if the length of the seed is not between 32 and 252 bytes inclusive.
///
/// [ZIP 316]: https://zips.z.cash/zip-0316
fn create_account(
&mut self,
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ impl Account {
}

// TODO: When a UnifiedIncomingViewingKey is available, add a function that
// will return it. Even if the Account was initialized with a UFVK, we can always
// derive a UIVK from that.
// will return it (external scope only). Even if the Account was initialized with a UFVK,
// we can always derive a UIVK from that.
}

/// Scans a [`Transaction`] for any information that can be decrypted by the accounts in
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_sqlite/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and this library adheres to Rust's notion of
- `create_account` function returns a unique identifier for the new account (as before),
except that this ID no longer happens to match the ZIP-32 account index.
To get the ZIP-32 account index, use the new `WalletRead::get_account` function.
- Two columns in the `transactions` view were renamed:
- Two columns in the `transactions` view were renamed. They refer to the primary key field in the `accounts` table, which no longer equates to a ZIP-32 account index.
- `to_account` -> `to_account_id`
- `from_account` -> `from_account_id`
- `zcash_client_sqlite::error::SqliteClientError` has changed variants:
Expand Down
3 changes: 1 addition & 2 deletions zcash_client_sqlite/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ pub enum SqliteClientError {
/// The account was imported, and ZIP-32 derivation information is not known for it.
UnknownZip32Derivation,

/// An error occurred deriving a spending key from a seed and an account
/// identifier.
/// An error occurred deriving a spending key from a seed and a ZIP-32 account index.
KeyDerivationError(zip32::AccountId),

/// A caller attempted to initialize the accounts table with a discontinuous
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ pub(crate) mod scanning;

pub(crate) const BLOCK_SAPLING_FRONTIER_ABSENT: &[u8] = &[0x0];

/// This tracks the allowed values of the `account_type` column of the `accounts` table
/// and should not be made public.
enum AccountType {
Zip32,
ImportedUfvk,
Expand Down Expand Up @@ -212,6 +214,7 @@ pub(crate) fn max_zip32_account_index(
)
}

/// Returns (account_type, hd_seed_fingerprint, hd_account_index, uvk) for a given account.
fn get_sql_values_for_account_parameters<'a, P: consensus::Parameters>(
account: &'a Account,
params: &P,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl RusqliteMigration for Migration {
CHECK (
(account_type = 0 AND hd_seed_fingerprint IS NOT NULL AND hd_account_index IS NOT NULL)
OR
(account_type = 1 AND hd_seed_fingerprint IS NULL AND hd_account_index IS NULL)
(account_type != 0 AND hd_seed_fingerprint IS NULL AND hd_account_index IS NULL)
)
);
CREATE UNIQUE INDEX accounts_uvk ON accounts_new ("uvk");
Expand Down
3 changes: 1 addition & 2 deletions zcash_keys/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ pub struct HdSeedFingerprint([u8; 32]);
impl HdSeedFingerprint {
/// Generates the fingerprint from a given seed.
///
/// # Panics
/// If the length of the seed is not between 32 and 252 bytes inclusive.
/// Panics if the length of the seed is not between 32 and 252 bytes inclusive.
pub fn from_seed(seed: &SecretVec<u8>) -> Self {
let len = seed.expose_secret().len();
let len = match len {
Expand Down

0 comments on commit 72506c6

Please sign in to comment.