Add -> TryAdd, Remove -> TryRemove
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -204,7 +204,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
try
{
IsBusy = true;
- MainWindowViewModel.Instance.StatusBar.AddStatus(buildingTransactionStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(buildingTransactionStatusText);
Password = Guard.Correct(Password);
Label = Label.Trim(',', ' ').Trim();
@@ -256,7 +256,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
const string dequeuingSelectedCoinsStatusText = "Dequeueing selected coins...";
try
{
- MainWindowViewModel.Instance.StatusBar.AddStatus(dequeuingSelectedCoinsStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(dequeuingSelectedCoinsStatusText);
TxoRef[] toDequeue = selectedCoinViewModels.Where(x => x.CoinJoinInProgress).Select(x => x.Model.GetTxoRef()).ToArray();
if (toDequeue != null && toDequeue.Any())
{
@@ -270,7 +270,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
finally
{
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(dequeuingSelectedCoinsStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(dequeuingSelectedCoinsStatusText);
}
var result = await Task.Run(() => Global.WalletService.BuildTransaction(Password, new[] { operation }, FeeTarget, allowUnconfirmed: true, allowedInputs: selectedCoinReferences));
@@ -291,7 +291,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return;
}
- MainWindowViewModel.Instance.StatusBar.AddStatus(signingTransactionStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(signingTransactionStatusText);
SmartTransaction signedTransaction = result.Transaction;
if (IsHardwareWallet && !result.Signed) // If hardware but still has a privkey then it's password, then meh.
@@ -302,7 +302,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
try
{
IsHardwareBusy = true;
- MainWindowViewModel.Instance.StatusBar.AddStatus(connectingToHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(connectingToHardwareWalletStatusText);
// If we have no hardware wallet info then try refresh it. If we failed, then tha's a problem.
if (KeyManager.HardwareWalletInfo is null && !await TryRefreshHardwareWalletInfoAsync(KeyManager))
{
@@ -310,14 +310,14 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return;
}
- MainWindowViewModel.Instance.StatusBar.AddStatus(acquiringSignatureFromHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(acquiringSignatureFromHardwareWalletStatusText);
signedPsbt = await HwiProcessManager.SignTxAsync(KeyManager.HardwareWalletInfo, result.Psbt);
}
catch (IOException ex) when (ex.Message.Contains("device not found", StringComparison.OrdinalIgnoreCase)
|| ex.Message.Contains("Invalid status 6f04", StringComparison.OrdinalIgnoreCase) // It comes when device asleep too.
|| ex.Message.Contains("Device is asleep", StringComparison.OrdinalIgnoreCase))
{
- MainWindowViewModel.Instance.StatusBar.AddStatus(connectingToHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(connectingToHardwareWalletStatusText);
// The user may changed USB port. Try again with new enumeration.
if (!await TryRefreshHardwareWalletInfoAsync(KeyManager))
{
@@ -325,19 +325,19 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return;
}
- MainWindowViewModel.Instance.StatusBar.AddStatus(acquiringSignatureFromHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(acquiringSignatureFromHardwareWalletStatusText);
signedPsbt = await HwiProcessManager.SignTxAsync(KeyManager.HardwareWalletInfo, result.Psbt);
}
finally
{
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(connectingToHardwareWalletStatusText, acquiringSignatureFromHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(connectingToHardwareWalletStatusText, acquiringSignatureFromHardwareWalletStatusText);
IsHardwareBusy = false;
}
signedTransaction = signedPsbt.ExtractSmartTransaction(result.Transaction.Height);
}
- MainWindowViewModel.Instance.StatusBar.AddStatus(broadcastingTransactionStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(broadcastingTransactionStatusText);
await Task.Run(async () => await Global.WalletService.SendTransactionAsync(signedTransaction));
TryResetInputsOnSuccess("Transaction is successfully sent!");
@@ -353,7 +353,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
finally
{
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(buildingTransactionStatusText, signingTransactionStatusText, broadcastingTransactionStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(buildingTransactionStatusText, signingTransactionStatusText, broadcastingTransactionStatusText);
IsBusy = false;
}
},

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
@@ -124,7 +124,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
transaction = new SmartTransaction(Transaction.Parse(TransactionString, Global.Network ?? Network.Main), WalletWasabi.Models.Height.Unknown);
}
- MainWindowViewModel.Instance.StatusBar.AddStatus(broadcastingTransactionStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(broadcastingTransactionStatusText);
await Task.Run(async () => await Global.WalletService.SendTransactionAsync(transaction));
SetSuccessMessage("Transaction is successfully sent!");
@@ -136,7 +136,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
finally
{
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(broadcastingTransactionStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(broadcastingTransactionStatusText);
IsBusy = false;
ButtonText = "Broadcast Transaction";
}

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -394,19 +394,19 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
try
{
IsHardwareBusy = true;
- MainWindowViewModel.Instance.StatusBar.AddStatus(settingUpHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(settingUpHardwareWalletStatusText);
if (!await HwiProcessManager.SetupAsync(selectedWallet.HardwareWalletInfo))
{
throw new Exception("Setup failed.");
}
- MainWindowViewModel.Instance.StatusBar.AddStatus(connectingToHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(connectingToHardwareWalletStatusText);
hwis = await HwiProcessManager.EnumerateAsync();
}
finally
{
IsHardwareBusy = false;
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(settingUpHardwareWalletStatusText, connectingToHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(settingUpHardwareWalletStatusText, connectingToHardwareWalletStatusText);
}
TryRefreshHardwareWallets(hwis);
@@ -424,12 +424,12 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
ExtPubKey extPubKey;
try
{
- MainWindowViewModel.Instance.StatusBar.AddStatus(acquiringXpubFromHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(acquiringXpubFromHardwareWalletStatusText);
extPubKey = await HwiProcessManager.GetXpubAsync(selectedWallet.HardwareWalletInfo);
}
finally
{
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(acquiringXpubFromHardwareWalletStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(acquiringXpubFromHardwareWalletStatusText);
}
Logger.LogInfo<LoadWalletViewModel>("Hardware wallet wasn't used previously on this computer. Creating new wallet file.");
@@ -533,7 +533,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
try
{
IsBusy = true;
- MainWindowViewModel.Instance.StatusBar.AddStatus(loadingStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryAddStatus(loadingStatusText);
var keyManager = await LoadKeyManagerAsync(IsPasswordRequired, IsHardwareWallet);
if (keyManager is null)
@@ -570,7 +570,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
}
finally
{
- MainWindowViewModel.Instance.StatusBar.RemoveStatus(loadingStatusText);
+ MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(loadingStatusText);
IsBusy = false;
}
}

MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -312,7 +312,9 @@ namespace WalletWasabi.Gui.ViewModels
private List<string> StatusQueue { get; } = new List<string>();
private object StatusQueueLock { get; } = new object();
- public void AddStatus(string status)
+ public void TryAddStatus(string status)
+ {
+ try
{
status = Guard.Correct(status);
if (status == "")
@@ -328,8 +330,15 @@ namespace WalletWasabi.Gui.ViewModels
RefreshStatusNoLock();
}
}
+ catch (Exception ex)
+ {
+ Logging.Logger.LogWarning<StatusBarViewModel>(ex);
+ }
+ }
- public void RemoveStatus(params string[] statuses)
+ public void TryRemoveStatus(params string[] statuses)
+ {
+ try
{
lock (StatusQueueLock)
{
@@ -348,6 +357,11 @@ namespace WalletWasabi.Gui.ViewModels
}
}
}
+ catch (Exception ex)
+ {
+ Logging.Logger.LogWarning<StatusBarViewModel>(ex);
+ }
+ }
private void RefreshStatus()
{

Add -> TryAdd, Remove -> TryRemove