Improve IsLikelyCoinjoin to perfection
MODIFY
WalletWasabi.Fluent/Rpc/WasabiJsonRpcService.cs
WalletWasabi.Fluent/Rpc/WasabiJsonRpcService.cs
@@ -196,7 +196,7 @@ public class WasabiJsonRpcService : IJsonRpcService
amount = x.Amount.Satoshi,
label = x.Label,
tx = x.TransactionId,
- islikelycoinjoin = x.IsLikelyOwnCoinjoin
+ islikelycoinjoin = x.IsOwnCoinjoin
}).ToArray();
}

MODIFY
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
@@ -101,7 +101,7 @@ public partial class WalletManagerViewModel : ViewModelBase
if (_walletDictionary.TryGetValue(wallet, out var walletViewModel) && walletViewModel is WalletViewModel wvm)
{
- if (!e.IsLikelyOwnCoinJoin)
+ if (!e.IsOwnCoinJoin)
{
NotificationHelpers.Show(wallet.WalletName, e, onClick: () => wvm.NavigateAndHighlight(e.Transaction.GetHash()));
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItems/CoinJoinsHistoryItemViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItems/CoinJoinsHistoryItemViewModel.cs
@@ -27,7 +27,7 @@ public class CoinJoinsHistoryItemViewModel : HistoryItemViewModelBase
public void Add(TransactionSummary item)
{
- if (!item.IsLikelyOwnCoinjoin)
+ if (!item.IsOwnCoinjoin)
{
throw new InvalidOperationException("Not a coinjoin item!");
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -136,12 +136,12 @@ public partial class HistoryViewModel : ActivatableViewModel
balance += item.Amount;
- if (!item.IsLikelyOwnCoinjoin)
+ if (!item.IsOwnCoinjoin)
{
yield return new TransactionHistoryItemViewModel(i, item, _walletViewModel, balance, _updateTrigger);
}
- if (item.IsLikelyOwnCoinjoin)
+ if (item.IsOwnCoinjoin)
{
if (coinJoinGroup is null)
{
@@ -154,7 +154,7 @@ public partial class HistoryViewModel : ActivatableViewModel
}
if (coinJoinGroup is { } cjg &&
- (i + 1 < txRecordList.Count && !txRecordList[i + 1].IsLikelyOwnCoinjoin || // The next item is not CJ so add the group.
+ (i + 1 < txRecordList.Count && !txRecordList[i + 1].IsOwnCoinjoin || // The next item is not CJ so add the group.
i == txRecordList.Count - 1)) // There is no following item in the list so add the group.
{
cjg.SetBalance(balance);

MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -108,7 +108,7 @@ public class TransactionProcessorTests
var res3 = results[2];
var res4 = results[3];
- Assert.False(res1.IsLikelyOwnCoinJoin);
+ Assert.False(res1.IsOwnCoinJoin);
Assert.Empty(res1.NewlyConfirmedReceivedCoins);
Assert.Empty(res1.NewlyConfirmedSpentCoins);
Assert.Single(res1.NewlyReceivedCoins);
@@ -122,7 +122,7 @@ public class TransactionProcessorTests
Assert.True(res1.IsNews);
Assert.NotNull(res1.Transaction);
- Assert.False(res2.IsLikelyOwnCoinJoin);
+ Assert.False(res2.IsOwnCoinJoin);
Assert.Single(res2.NewlyConfirmedReceivedCoins);
Assert.Empty(res2.NewlyConfirmedSpentCoins);
Assert.Empty(res2.NewlyReceivedCoins);
@@ -136,7 +136,7 @@ public class TransactionProcessorTests
Assert.True(res2.IsNews);
Assert.NotNull(res2.Transaction);
- Assert.False(res3.IsLikelyOwnCoinJoin);
+ Assert.False(res3.IsOwnCoinJoin);
Assert.Empty(res3.NewlyConfirmedReceivedCoins);
Assert.Empty(res3.NewlyConfirmedSpentCoins);
Assert.Empty(res3.NewlyReceivedCoins);
@@ -150,7 +150,7 @@ public class TransactionProcessorTests
Assert.True(res3.IsNews);
Assert.NotNull(res3.Transaction);
- Assert.False(res4.IsLikelyOwnCoinJoin);
+ Assert.False(res4.IsOwnCoinJoin);
Assert.Empty(res4.NewlyConfirmedReceivedCoins);
Assert.Single(res4.NewlyConfirmedSpentCoins);
Assert.Empty(res4.NewlyReceivedCoins);

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/ProcessedResult.cs
WalletWasabi/Blockchain/TransactionProcessing/ProcessedResult.cs
@@ -9,12 +9,12 @@ namespace WalletWasabi.Blockchain.TransactionProcessing;
public class ProcessedResult
{
- private Lazy<bool> _isLikelyOwnCoinJoin;
+ private Lazy<bool> _isOwnCoinJoin;
public ProcessedResult(SmartTransaction transaction)
{
Transaction = Guard.NotNull(nameof(transaction), transaction);
- _isLikelyOwnCoinJoin = new Lazy<bool>(() => Transaction.IsLikelyOwnCoinjoin(), true);
+ _isOwnCoinJoin = new Lazy<bool>(() => Transaction.IsOwnCoinjoin(), true);
}
public SmartTransaction Transaction { get; }
@@ -29,7 +29,7 @@ public class ProcessedResult
|| 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 => _isLikelyOwnCoinJoin.Value;
+ public bool IsOwnCoinJoin => _isOwnCoinJoin.Value;
/// <summary>
/// Gets the dust outputs we received in this transaction. We may or may not have known about

MODIFY
WalletWasabi/Blockchain/Transactions/SmartTransaction.cs
WalletWasabi/Blockchain/Transactions/SmartTransaction.cs
@@ -192,11 +192,9 @@ public class SmartTransaction : IEquatable<SmartTransaction>
BlockIndex = 0;
}
- public bool IsLikelyOwnCoinjoin()
+ public bool IsOwnCoinjoin()
=> WalletInputs.Any() // We must be a participant in order to be this transaction our coinjoin.
- && Transaction.Inputs.Count != WalletInputs.Count // Some inputs must not be ours for it to be a coinjoin.
- && Transaction.Outputs.Count != WalletOutputs.Count // Some outputs must not be ours for it to be a coinjoin.
- && Transaction.HasIndistinguishableOutputs(); // The tx must have more than one equal output in order to be a coinjoin.
+ && Transaction.Inputs.Count != WalletInputs.Count; // Some inputs must not be ours for it to be a coinjoin.
#region LineSerialization

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionHistoryBuilder.cs
WalletWasabi/Blockchain/Transactions/TransactionHistoryBuilder.cs
@@ -49,7 +49,7 @@ public class TransactionHistoryBuilder
Label = containingTransaction.Label,
TransactionId = coin.TransactionId,
BlockIndex = containingTransaction.BlockIndex,
- IsLikelyOwnCoinjoin = containingTransaction.IsLikelyOwnCoinjoin()
+ IsOwnCoinjoin = containingTransaction.IsOwnCoinjoin()
});
}
@@ -74,7 +74,7 @@ public class TransactionHistoryBuilder
Label = spenderTransaction.Label,
TransactionId = spenderTxId,
BlockIndex = spenderTransaction.BlockIndex,
- IsLikelyOwnCoinjoin = spenderTransaction.IsLikelyOwnCoinjoin()
+ IsOwnCoinjoin = spenderTransaction.IsOwnCoinjoin()
});
}
}

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionSummary.cs
WalletWasabi/Blockchain/Transactions/TransactionSummary.cs
@@ -12,5 +12,5 @@ public class TransactionSummary
public SmartLabel Label { get; set; }
public uint256 TransactionId { get; set; }
public int BlockIndex { get; set; }
- public bool IsLikelyOwnCoinjoin { get; set; }
+ public bool IsOwnCoinjoin { get; set; }
}

Improve IsLikelyCoinjoin to perfection