Skip to content

Commit

Permalink
fix: added transaction revalidation to the wallet startup sequence #5227
Browse files Browse the repository at this point in the history
 (#5246)

Description
---
Now wallet revalidates all transactions included in the wallet on
startup.

#5227

Motivation and Context
---
Outputs fetched from a fully synced node could be invalidated by the
transaction validator, e.g. wallet has normal outputs,
fully validated, but at some point become invalidated when the wallet is
trying to negotiate with another, not yet fully synced node that doesn't
recognise said output due to not reaching its height at the moment.

So, the code was already there but not yet used in the startup process.

How Has This Been Tested?
---
manually

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->

Co-authored-by: SW van Heerden <swvheerden@gmail.com>
  • Loading branch information
agubarev and SWvheerden authored Mar 15, 2023
1 parent 30c4e8b commit 7b4e2d2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion applications/tari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,19 @@ pub async fn start_wallet(
})?;

// Restart transaction protocols if not running in script or command modes

if !matches!(wallet_mode, WalletMode::Command(_)) && !matches!(wallet_mode, WalletMode::Script(_)) {
// NOTE: https://github.com/tari-project/tari/issues/5227
debug!("revalidating all transactions");
if let Err(e) = wallet.transaction_service.revalidate_all_transactions().await {
error!(target: LOG_TARGET, "Failed to revalidate all transactions: {}", e);
}

debug!("restarting transaction protocols");
if let Err(e) = wallet.transaction_service.restart_transaction_protocols().await {
error!(target: LOG_TARGET, "Problem restarting transaction protocols: {}", e);
}

debug!("validating transactions");
if let Err(e) = wallet.transaction_service.validate_transactions().await {
error!(
target: LOG_TARGET,
Expand All @@ -495,6 +503,7 @@ pub async fn start_wallet(
// validate transaction outputs
validate_txos(wallet).await?;
}

Ok(())
}

Expand Down

0 comments on commit 7b4e2d2

Please sign in to comment.