Reorg transactions.
MODIFY
WalletWasabi/Blockchain/Transactions/AllTransactionStore.cs
WalletWasabi/Blockchain/Transactions/AllTransactionStore.cs
@@ -230,6 +230,29 @@ namespace WalletWasabi.Blockchain.Transactions
}
}
+ public IEnumerable<SmartTransaction> TryReorg(uint256 invalidBlockHash)
+ {
+ lock (Lock)
+ {
+ List<SmartTransaction> reorgedTxs = new List<SmartTransaction>();
+ foreach (var txHash in ConfirmedStore
+ .GetTransactions()
+ .Where(tx => tx.BlockHash == invalidBlockHash)
+ .Select(tx => tx.GetHash()))
+ {
+ if (ConfirmedStore.TryRemove(txHash, out SmartTransaction removedTx))
+ {
+ removedTx.SetUnconfirmed();
+ if (MempoolStore.TryAddOrUpdate(removedTx).isAdded)
+ {
+ reorgedTxs.Add(removedTx);
+ }
+ }
+ }
+ return reorgedTxs;
+ }
+ }
+
#endregion Accessors
}
}

MODIFY
WalletWasabi/Blockchain/Transactions/SmartTransaction.cs
WalletWasabi/Blockchain/Transactions/SmartTransaction.cs
@@ -172,6 +172,19 @@ namespace WalletWasabi.Blockchain.Transactions
});
}
+ public bool SetUnconfirmed()
+ {
+ if (!Confirmed)
+ {
+ return false;
+ }
+
+ Height = Height.Mempool;
+ BlockHash = null;
+ BlockIndex = 0;
+ return true;
+ }
+
#region LineSerialization
public string ToLine()

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -194,6 +194,7 @@ namespace WalletWasabi.Services
if (blockState != null && blockState.BlockHeight != default(Height))
{
TransactionProcessor.UndoBlock(blockState.BlockHeight);
+ BitcoinStore.TransactionStore.TryReorg(invalidBlockHash);
}
}
}

Reorg transactions.