Skip to content

Commit

Permalink
Fix implicit account creation address sync for non Ed25519 addresses (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Co-authored-by: DaughterOfMars <[email protected]>
  • Loading branch information
3 people authored Mar 4, 2024
1 parent 7b4b31e commit 747e68b
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions sdk/src/wallet/operations/syncing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
Expand Down

0 comments on commit 747e68b

Please sign in to comment.