don't run Zcash address init twice when opening a wallet (#3784)
What changed, and why it matters
This is a performance fix, not a security fix. When opening or creating a Zcash wallet, the app was accidentally running the same address-setup work twice in parallel. The change makes the wallet do it once, saving about a second on slow phones. There is no indication this caused funds to be lost, stolen, or misdirected.
Treat as a routine performance/reliability improvement. No security response required. If desired, verify that no other wallet address classes use a setter that triggers init() inside a constructor.
Security signals we found
Redundant initialization removed
Potential race condition between parallel init passes eliminated
No cryptographic, authentication, or authorization changes
No input validation or boundary changes
Evidence from the diff
In cw_zcash/lib/src/zcash_wallet_addresses.dart, the ZcashWalletAddressesBase constructor previously assigned addressPageType via its setter. That setter also triggers init(), which performs rotation-pool queries and an address-book save. ZcashWallet.init() then calls walletAddresses.init() again, so the expensive init ran twice concurrently. The patch assigns the backing field _addressPageType directly in the constructor, deferring initialization to the single ZcashWallet.init() call that always follows. This removes redundant work and a potential race between parallel init passes.
Changed components
cw_zcash/lib/src/zcash_wallet_addresses.dartZcash wallet open/create/restore flowInspect captured patch +2 / −1
### cw_zcash/lib/src/zcash_wallet_addresses.dart
@@ -14,7 +14,8 @@ class ZcashWalletAddresses = ZcashWalletAddressesBase with _$ZcashWalletAddresse
abstract class ZcashWalletAddressesBase extends WalletAddresses with Store {
ZcashWalletAddressesBase(this.accountId, final WalletInfo walletInfo) : super(walletInfo) {
- addressPageType = ZcashReceivePageOption.typeFromString(walletInfo.addressPageType ?? "");
+ // Not through the setter: that also runs init(), which the wallet's init() runs right after
+ _addressPageType = ZcashReceivePageOption.typeFromString(walletInfo.addressPageType ?? "");
}
int accountId;Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.