Check for null Global.WalletService
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -123,39 +123,32 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private static List<(DateTimeOffset dateTime, Height height, Money amount, string label, uint256 transactionId)> BuildTxRecordList()
{
+ var walletService = Global.WalletService;
+
List<Transaction> trs = new List<Transaction>();
var txRecordList = new List<(DateTimeOffset dateTime, Height height, Money amount, string label, uint256 transactionId)>();
- foreach (SmartCoin coin in Global.WalletService.Coins)
- {
- var found = txRecordList.FirstOrDefault(x => x.transactionId == coin.TransactionId);
- if (Global.WalletService is null)
+ if(walletService == null)
{
- break; // Disposed meanwhile.
+ return txRecordList;
}
- SmartTransaction foundTransaction = Global.WalletService?.TransactionCache?.FirstOrDefault(x => x.GetHash() == coin.TransactionId);
- if (foundTransaction is null)
- {
- if (Global.WalletService is null)
+ foreach (SmartCoin coin in walletService.Coins)
{
- break; // Disposed meanwhile.
- }
+ var found = txRecordList.FirstOrDefault(x => x.transactionId == coin.TransactionId);
+ SmartTransaction foundTransaction = walletService.TransactionCache?.FirstOrDefault(x => x.GetHash() == coin.TransactionId);
+ if (foundTransaction is null)
+ {
continue;
}
DateTimeOffset dateTime;
if (foundTransaction.Height.Type == HeightType.Chain)
{
- if (Global.WalletService is null)
- {
- break; // Disposed meanwhile. Actually caught an NRE here.
- }
-
- if (Global.WalletService.ProcessedBlocks.Any(x => x.Value.height == foundTransaction.Height))
+ if (walletService.ProcessedBlocks.Any(x => x.Value.height == foundTransaction.Height))
{
- dateTime = Global.WalletService.ProcessedBlocks.First(x => x.Value.height == foundTransaction.Height).Value.dateTime;
+ dateTime = walletService.ProcessedBlocks.First(x => x.Value.height == foundTransaction.Height).Value.dateTime;
}
else
{
@@ -180,16 +173,16 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (coin.SpenderTransactionId != null)
{
- SmartTransaction foundSpenderTransaction = Global.WalletService.TransactionCache.First(x => x.GetHash() == coin.SpenderTransactionId);
+ SmartTransaction foundSpenderTransaction = walletService.TransactionCache.First(x => x.GetHash() == coin.SpenderTransactionId);
if (foundSpenderTransaction.Height.Type == HeightType.Chain)
{
- if (Global.WalletService?.ProcessedBlocks != null) // NullReferenceException appeared here.
+ if (walletService.ProcessedBlocks != null) // NullReferenceException appeared here.
{
- if (Global.WalletService.ProcessedBlocks.Any(x => x.Value.height == foundSpenderTransaction.Height))
+ if (walletService.ProcessedBlocks.Any(x => x.Value.height == foundSpenderTransaction.Height))
{
- if (Global.WalletService?.ProcessedBlocks != null) // NullReferenceException appeared here.
+ if (walletService.ProcessedBlocks != null) // NullReferenceException appeared here.
{
- dateTime = Global.WalletService.ProcessedBlocks.First(x => x.Value.height == foundSpenderTransaction.Height).Value.dateTime;
+ dateTime = walletService.ProcessedBlocks.First(x => x.Value.height == foundSpenderTransaction.Height).Value.dateTime;
}
else
{

Check for null Global.WalletService