Skip to content

Commit

Permalink
zcash_client_sqlite: Skip gap address generation if no transparent ke…
Browse files Browse the repository at this point in the history
…y is available.
  • Loading branch information
nuttycom committed Mar 5, 2025
1 parent 0cd8838 commit d255a29
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions zcash_client_sqlite/src/wallet/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ pub(crate) fn generate_gap_addresses<P: consensus::Parameters>(
let account = get_account_internal(conn, params, account_id)?
.ok_or_else(|| SqliteClientError::AccountUnknown)?;

if !account.uivk().has_transparent() {
return Ok(());
}

let gen_addrs = |key_scope: KeyScope, index: NonHardenedChildIndex| {
Ok::<_, SqliteClientError>(match key_scope {
KeyScope::Zip32(zip32::Scope::External) => {
Expand All @@ -426,7 +430,7 @@ pub(crate) fn generate_gap_addresses<P: consensus::Parameters>(
.uivk()
.transparent()
.as_ref()
.ok_or(AddressGenerationError::KeyNotAvailable(Typecode::P2pkh))?
.expect("presence of transparent key was checked above.")
.derive_address(index)?;
(
ua.map_or_else(
Expand All @@ -448,7 +452,7 @@ pub(crate) fn generate_gap_addresses<P: consensus::Parameters>(
let internal_address = account
.ufvk()
.and_then(|k| k.transparent())
.ok_or(AddressGenerationError::KeyNotAvailable(Typecode::P2pkh))?
.expect("presence of transparent key was checked above.")
.derive_internal_ivk()?
.derive_address(index)?;
(
Expand All @@ -460,7 +464,7 @@ pub(crate) fn generate_gap_addresses<P: consensus::Parameters>(
let ephemeral_address = account
.ufvk()
.and_then(|k| k.transparent())
.ok_or(AddressGenerationError::KeyNotAvailable(Typecode::P2pkh))?
.expect("presence of transparent key was checked above.")
.derive_ephemeral_ivk()?
.derive_ephemeral_address(index)?;
(
Expand Down

0 comments on commit d255a29

Please sign in to comment.