From f9c9201db0886ba2c9643b047f240ceec42bfc29 Mon Sep 17 00:00:00 2001 From: Philip Robinson Date: Wed, 6 Oct 2021 21:38:33 +0200 Subject: [PATCH] fix: handle recovering a duplicate output (#3426) Description --- If a batch of wallet recovery queries was interrupted (either due to a connection issue or the app restarting) then it was possible for a UTXO to be rescanned. The recoverer tried to import a duplicate output which produced an error. This PR catches that case, prints a log and continues. How Has This Been Tested? --- Manually --- .../recovery/standard_outputs_recoverer.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/base_layer/wallet/src/output_manager_service/recovery/standard_outputs_recoverer.rs b/base_layer/wallet/src/output_manager_service/recovery/standard_outputs_recoverer.rs index 1da885d7f1..f3386a30ea 100644 --- a/base_layer/wallet/src/output_manager_service/recovery/standard_outputs_recoverer.rs +++ b/base_layer/wallet/src/output_manager_service/recovery/standard_outputs_recoverer.rs @@ -32,7 +32,7 @@ use tari_core::transactions::{ }; use crate::output_manager_service::{ - error::OutputManagerError, + error::{OutputManagerError, OutputManagerStorageError}, storage::{ database::{OutputManagerBackend, OutputManagerDatabase}, models::DbUnblindedOutput, @@ -110,7 +110,18 @@ where TBackend: OutputManagerBackend + 'static .await?; let db_output = DbUnblindedOutput::from_unblinded_output(output.clone(), &self.factories)?; - self.db.add_unspent_output(db_output).await?; + let output_hex = db_output.commitment.to_hex(); + if let Err(e) = self.db.add_unspent_output(db_output).await { + match e { + OutputManagerStorageError::DuplicateOutput => { + info!( + target: LOG_TARGET, + "Recoverer attempted to import a duplicate output (Commitment: {})", output_hex + ); + }, + _ => return Err(OutputManagerError::from(e)), + } + } trace!( target: LOG_TARGET,