From 747e68b035330bf3bea7a9eee5cc0198e2a5cf20 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:57:08 +0100 Subject: [PATCH] Fix implicit account creation address sync for non Ed25519 addresses (#2114) * Fix implicit account creation address sync for non Ed25519 addresses * Update sdk/src/wallet/operations/syncing/mod.rs * Add address check * Use implicit_account_creation_address * use implicit_accounts() --------- Co-authored-by: Thibault Martinez Co-authored-by: DaughterOfMars --- sdk/src/wallet/operations/syncing/mod.rs | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sdk/src/wallet/operations/syncing/mod.rs b/sdk/src/wallet/operations/syncing/mod.rs index f873a8c4f1..fa5ed8569e 100644 --- a/sdk/src/wallet/operations/syncing/mod.rs +++ b/sdk/src/wallet/operations/syncing/mod.rs @@ -99,16 +99,30 @@ where output_ids: self.ledger().await.unspent_outputs().keys().copied().collect(), }; - let address_to_sync = vec![ - wallet_address_with_unspent_outputs, - AddressWithUnspentOutputs { - address: self.implicit_account_creation_address().await?, - output_ids: vec![], - }, - ]; + let mut addresses_to_sync = vec![wallet_address_with_unspent_outputs]; + + if options.sync_implicit_accounts { + if let Ok(implicit_account_creation_address) = self.implicit_account_creation_address().await { + addresses_to_sync.push(AddressWithUnspentOutputs { + output_ids: self + .ledger() + .await + .implicit_accounts() + .filter_map(|output_data| { + if output_data.output.as_basic().address() == implicit_account_creation_address.inner() { + Some(output_data.output_id) + } else { + None + } + }) + .collect(), + address: implicit_account_creation_address, + }); + } + } let (_addresses_with_unspent_outputs, spent_or_not_synced_output_ids, outputs_data) = - self.request_outputs_recursively(address_to_sync, options).await?; + self.request_outputs_recursively(addresses_to_sync, options).await?; // Request possible spent outputs log::debug!("[SYNC] spent_or_not_synced_outputs: {spent_or_not_synced_output_ids:?}");