Replace replacement event
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -442,7 +442,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.DisposeWith(Disposables);
Observable
- .Merge(Observable.FromEventPattern<ReplaceTransactionReceivedEventArgs>(Global.WalletService.TransactionProcessor, nameof(Global.WalletService.TransactionProcessor.ReplaceTransactionReceived)).Select(_ => Unit.Default))
.Merge(Observable.FromEventPattern<TransactionProcessedResult>(Global.WalletService.TransactionProcessor, nameof(Global.WalletService.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default))
.Merge(Observable.FromEventPattern<TxCoinsEventArgs>(Global.WalletService.TransactionProcessor, nameof(Global.WalletService.TransactionProcessor.CoinsSpent)).Select(_ => Unit.Default))
.Merge(Observable.FromEventPattern<TxCoinsEventArgs>(Global.WalletService.TransactionProcessor, nameof(Global.WalletService.TransactionProcessor.CoinsReceived)).Select(_ => Unit.Default))

MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -228,7 +228,9 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
var transactionProcessor = await CreateTransactionProcessorAsync();
int replaceTransactionReceivedCalled = 0;
- transactionProcessor.ReplaceTransactionReceived += (s, e) =>
+ transactionProcessor.WalletRelevantTransactionProcessed += (s, e) =>
+ {
+ if (e.ReplacedCoins.Any() || e.RestoredCoins.Any())
{
// Move the original coin from spent to unspent - so add.
var originalCoin = Assert.Single(e.RestoredCoins);
@@ -241,6 +243,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.Single(e.ReplacedCoins, coin => coin.HdPubKey.Label == "D");
replaceTransactionReceivedCalled++;
+ }
};
// A confirmed segwit transaction for us

DELETE
WalletWasabi/Blockchain/TransactionProcessing/ReplaceTransactionReceivedEventArgs.cs
-using System;
-using System.Collections.Generic;
-using WalletWasabi.Blockchain.TransactionOutputs;
-using WalletWasabi.Blockchain.Transactions;
-
-namespace WalletWasabi.Blockchain.TransactionProcessing
-{
- public class ReplaceTransactionReceivedEventArgs : EventArgs
- {
- public ReplaceTransactionReceivedEventArgs(SmartTransaction smartTransaction, IEnumerable<SmartCoin> replacedCoins, IEnumerable<SmartCoin> restoredCoins) : base()
- {
- SmartTransaction = smartTransaction;
- ReplacedCoins = replacedCoins;
- RestoredCoins = restoredCoins;
- }
-
- public SmartTransaction SmartTransaction { get; }
- public IEnumerable<SmartCoin> ReplacedCoins { get; }
- public IEnumerable<SmartCoin> RestoredCoins { get; }
- }
-}

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessedResult.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessedResult.cs
@@ -11,7 +11,7 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
public class TransactionProcessedResult
{
public SmartTransaction Transaction { get; }
- public bool IsWalletRelevant => SuccessfullyDoubleSpentCoins.Any();
+ public bool IsWalletRelevant => SuccessfullyDoubleSpentCoins.Any() || ReplacedCoins.Any() || RestoredCoins.Any();
public bool IsLikelyOwnCoinJoin { get; set; } = false;
/// <summary>
@@ -21,6 +21,16 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
/// </summary>
public List<SmartCoin> SuccessfullyDoubleSpentCoins { get; set; } = new List<SmartCoin>();
+ /// <summary>
+ /// Unconfirmed coins those were replaced by the coins of the transaction.
+ /// </summary>
+ public List<SmartCoin> ReplacedCoins { get; set; } = new List<SmartCoin>();
+
+ /// <summary>
+ /// Coins those were made unspent again by this double spend transaction.
+ /// </summary>
+ public List<SmartCoin> RestoredCoins { get; set; } = new List<SmartCoin>();
+
public TransactionProcessedResult(SmartTransaction transaction)
{
Transaction = Guard.NotNull(nameof(transaction), transaction);

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -28,8 +28,6 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
public event EventHandler<TxCoinsEventArgs> CoinsReceived;
- public event EventHandler<ReplaceTransactionReceivedEventArgs> ReplaceTransactionReceived;
-
public TransactionProcessor(
AllTransactionStore transactionStore,
KeyManager keyManager,
@@ -69,7 +67,10 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
{
ret = ProcessNoLock(tx);
}
+ if (ret.IsWalletRelevant)
+ {
WalletRelevantTransactionProcessed?.Invoke(this, ret);
+ }
return ret;
}
@@ -133,7 +134,8 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
var replacedTxId = doubleSpends.First().TransactionId;
var (replaced, restored) = Coins.Undo(replacedTxId);
- ReplaceTransactionReceived?.Invoke(this, new ReplaceTransactionReceivedEventArgs(tx, replaced, restored));
+ result.ReplacedCoins.AddRange(replaced);
+ result.ReplacedCoins.AddRange(restored);
foreach (var replacedTransactionId in replaced.Select(coin => coin.TransactionId))
{

Replace replacement event