Skip to content

Commit

Permalink
fix: handle recovering a duplicate output (#3426)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
philipr-za committed Oct 6, 2021
1 parent 6578d1e commit f9c9201
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -32,7 +32,7 @@ use tari_core::transactions::{
};

use crate::output_manager_service::{
error::OutputManagerError,
error::{OutputManagerError, OutputManagerStorageError},
storage::{
database::{OutputManagerBackend, OutputManagerDatabase},
models::DbUnblindedOutput,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f9c9201

Please sign in to comment.