From a4e8b53817f85fbe2c652f9d5b7aaf9e4748ff84 Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Fri, 17 Apr 2026 00:09:32 -0300 Subject: [PATCH] fix wallet storage bug --- wallet/src/helperfunctions.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wallet/src/helperfunctions.rs b/wallet/src/helperfunctions.rs index e1c5b753..dcd75b28 100644 --- a/wallet/src/helperfunctions.rs +++ b/wallet/src/helperfunctions.rs @@ -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 {