fix wallet storage bug

This commit is contained in:
Sergio Chouhy 2026-04-17 00:09:32 -03:00
parent 3cf7972425
commit a4e8b53817

View File

@ -165,6 +165,9 @@ pub fn produce_data_for_storage(
}
}
let covered_private_chain_indices: std::collections::BTreeSet<_> =
user_data.private_key_tree.account_id_map.values().cloned().collect();
for (account_id, key) in &user_data.private_key_tree.account_id_map {
if let Some(data) = user_data.private_key_tree.key_map.get(key) {
vec_for_storage.push(
@ -178,6 +181,24 @@ pub fn produce_data_for_storage(
}
}
// Also persist fresh nodes that have no identifiers yet and are therefore absent from
// account_id_map. Without this, a restart before the first sync would lose the node
// entirely, making it impossible to detect incoming transfers.
for (chain_index, node) in &user_data.private_key_tree.key_map {
if !covered_private_chain_indices.contains(chain_index) {
let account_id =
nssa::AccountId::from((&node.value.0.nullifier_public_key, 0_u128));
vec_for_storage.push(
PersistentAccountDataPrivate {
account_id,
chain_index: chain_index.clone(),
data: node.clone(),
}
.into(),
);
}
}
for (account_id, key) in &user_data.default_pub_account_signing_keys {
vec_for_storage.push(
InitialAccountData::Public(PublicAccountPrivateInitialData {