Delegate IsLikelyOwnCoinjoin analysis to later.
MODIFY
WalletWasabi/Blockchain/TransactionProcessing/ProcessedResult.cs
WalletWasabi/Blockchain/TransactionProcessing/ProcessedResult.cs
using NBitcoin;
+using System;
using System.Collections.Generic;
using System.Linq;
using WalletWasabi.Blockchain.TransactionOutputs;
@@ -9,9 +10,12 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
{
public class ProcessedResult
{
+ private Lazy<bool> _isLikelyOwnCoinJoin;
+
public ProcessedResult(SmartTransaction transaction)
{
Transaction = Guard.NotNull(nameof(transaction), transaction);
+ _isLikelyOwnCoinJoin = new Lazy<bool>(() => Transaction.WalletInputs.Any() && Transaction.Transaction.IsLikelyCoinjoin(), true);
}
public SmartTransaction Transaction { get; }
@@ -26,7 +30,7 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
|| NewlyConfirmedSpentCoins.Any()
|| ReceivedDusts.Any(); // To be fair it isn't necessarily news, the algorithm of the processor can be improved for that. Not sure it is worth it though.
- public bool IsLikelyOwnCoinJoin { get; set; } = false;
+ public bool IsLikelyOwnCoinJoin => _isLikelyOwnCoinJoin.Value;
/// <summary>
/// Gets the dust outputs we received in this transaction. We may or may not have known about

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -221,7 +221,6 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
}
}
- bool? isLikelyCj = null;
// If spends any of our coin
foreach (var coin in Coins.AsAllCoinsView().OutPoints(tx.Transaction.Inputs.Select(x => x.PrevOut).ToHashSet()))
{
@@ -238,9 +237,6 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
{
result.NewlyConfirmedSpentCoins.Add(coin);
}
-
- isLikelyCj ??= tx.Transaction.IsLikelyCoinjoin();
- result.IsLikelyOwnCoinJoin = isLikelyCj is true;
}
if (result.IsNews)

Delegate IsLikelyOwnCoinjoin analysis to later.