wallet: Fix account generation bug
When generating a new account, we were setting up the map from account ID to UFVK ID, but were not setting up the reverse map from UFVK ID to account ID. The latter map is needed in order to verify that a note in the wallet belongs to the account. We were correctly loading it from the account metadata on node start, but between account generation and first restart, z_getbalanceforaccount would always return zero. We now initialize the UFVK address metadata map with the account ID when the account is generated.
This commit is contained in:
parent
ca0dad0a8c
commit
77c46933aa
|
@ -469,8 +469,15 @@ std::optional<libzcash::ZcashdUnifiedSpendingKey>
|
|||
// metadata that can be used to re-derive the spending key along with
|
||||
// the fingerprint of the associated full viewing key.
|
||||
|
||||
// Set up the bidirectional maps between the account ID and the UFVK ID.
|
||||
auto metaKey = std::make_pair(skmeta.GetSeedFingerprint(), skmeta.GetAccountId());
|
||||
mapUnifiedAccountKeys.insert({metaKey, skmeta.GetKeyID()});
|
||||
mapUnifiedAccountKeys.insert({metaKey, ufvkid});
|
||||
// We set up the UFVKAddressMetadata with the correct account ID (so we identify
|
||||
// the UFVK as corresponding to this account) and empty receivers data (as we
|
||||
// haven't generated any addresses yet). We don't need to persist this directly,
|
||||
// because we persist skmeta below, and mapUfvkAddressMetadata is populated in
|
||||
// LoadUnifiedAccountMetadata().
|
||||
mapUfvkAddressMetadata.insert({ufvkid, UFVKAddressMetadata(accountId)});
|
||||
|
||||
// Add Transparent component to the wallet
|
||||
AddTransparentSecretKey(
|
||||
|
|
Loading…
Reference in New Issue