Add WalletName to Notifications
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/BuildTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/BuildTabViewModel.cs
@@ -32,7 +32,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
ResetUi();
- NotificationHelpers.Success("Transaction was built.");
+ NotificationHelpers.Success("Transaction was built.", sender: Wallet);
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
@@ -31,7 +31,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- NotificationHelpers.Error($"Couldn't load wallet: {Title}. Reason: {ex.ToUserFriendlyString()}");
+ NotificationHelpers.Error($"Couldn't load wallet. Reason: {ex.ToUserFriendlyString()}", sender: wallet);
Logger.LogError(ex);
}
}, this.WhenAnyValue(x => x.WalletState).Select(x => x == WalletState.Uninitialized));

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -318,7 +318,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!coins.Any())
{
- NotificationHelpers.Warning("No coins are selected.", "");
+ NotificationHelpers.Warning("No coins are selected.", "", sender: Wallet);
return;
}
@@ -346,7 +346,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!coins.Any())
{
- NotificationHelpers.Warning("No coins are selected.", "");
+ NotificationHelpers.Warning("No coins are selected.", "", sender: Wallet);
return;
}
try
@@ -356,14 +356,14 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (compatiblityPassword != null)
{
Password = compatiblityPassword;
- NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage);
+ NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage, sender: Wallet);
}
await Wallet.ChaumianClient.QueueCoinsToMixAsync(Password, coins.ToArray());
}
catch (SecurityException ex)
{
- NotificationHelpers.Error(ex.Message, "");
+ NotificationHelpers.Error(ex.Message, "", sender: Wallet);
}
catch (Exception ex)
{
@@ -375,7 +375,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
builder.Append(Environment.NewLine + iex.ToTypeMessageString());
}
}
- NotificationHelpers.Error(builder.ToString());
+ NotificationHelpers.Error(builder.ToString(), sender: Wallet);
Logger.LogError(ex);
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -40,7 +40,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.Subscribe(ex =>
{
Logger.LogError(ex);
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: wallet);
});
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -42,7 +42,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
LabelSuggestion.Label = label;
if (label.IsEmpty)
{
- NotificationHelpers.Warning("Observers are required.");
+ NotificationHelpers.Warning("Observers are required.", sender: Wallet);
return;
}
@@ -53,7 +53,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
int minGapLimit = Wallet.KeyManager.MinGapLimit.Value;
int prevMinGapLimit = minGapLimit - 1;
- NotificationHelpers.Warning($"{nameof(KeyManager.MinGapLimit)} increased from {prevMinGapLimit} to {minGapLimit}.");
+ NotificationHelpers.Warning($"{nameof(KeyManager.MinGapLimit)} increased from {prevMinGapLimit} to {minGapLimit}.", sender: Wallet);
}
var newAddress = new AddressViewModel(newKey, Wallet.KeyManager, this);
@@ -80,7 +80,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.Subscribe(ex =>
{
Logger.LogError(ex);
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: Wallet);
});
}
@@ -88,7 +88,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public ReactiveCommand<Unit, Unit> GenerateCommand { get; }
- private Wallet Wallet { get; }
+ public Wallet Wallet { get; }
Wallet IWalletViewModel.Wallet => Wallet;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -229,7 +229,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
LabelSuggestion.Label = label;
if (!IsMax && label.IsEmpty)
{
- NotificationHelpers.Warning("Observers are required.", "");
+ NotificationHelpers.Warning("Observers are required.", "", sender: Wallet);
return;
}
@@ -238,7 +238,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (!selectedCoinReferences.Any())
{
- NotificationHelpers.Warning("No coins are selected to spend.", "");
+ NotificationHelpers.Warning("No coins are selected to spend.", "", sender: Wallet);
return;
}
@@ -249,7 +249,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (FormatException)
{
- NotificationHelpers.Warning("Invalid address.", "");
+ NotificationHelpers.Warning("Invalid address.", "", sender: Wallet);
return;
}
@@ -263,7 +263,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (customChangeAddress == address)
{
- NotificationHelpers.Warning("The active address and the change address cannot be the same.", "");
+ NotificationHelpers.Warning("The active address and the change address cannot be the same.", "", sender: Wallet);
return;
}
@@ -271,7 +271,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (FormatException)
{
- NotificationHelpers.Warning("Invalid custom change address.", "");
+ NotificationHelpers.Warning("Invalid custom change address.", "", sender: Wallet);
return;
}
}
@@ -285,13 +285,13 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!Money.TryParse(AmountText, out Money amount) || amount == Money.Zero)
{
- NotificationHelpers.Warning("Invalid amount.");
+ NotificationHelpers.Warning("Invalid amount.", sender: Wallet);
return;
}
if (amount == selectedCoinViewModels.Sum(x => x.Amount))
{
- NotificationHelpers.Warning("Looks like you want to spend whole coins. Try Max button instead.", "");
+ NotificationHelpers.Warning("Looks like you want to spend whole coins. Try Max button instead.", "", sender: Wallet);
return;
}
moneyRequest = MoneyRequest.Create(amount, subtractFee: false);
@@ -299,7 +299,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (FeeRate is null || FeeRate.SatoshiPerByte < 1)
{
- NotificationHelpers.Warning("Invalid fee rate.", "");
+ NotificationHelpers.Warning("Invalid fee rate.", "", sender: Wallet);
return;
}
@@ -320,7 +320,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch
{
- NotificationHelpers.Error("Cannot spend mixing coins.", "");
+ NotificationHelpers.Error("Cannot spend mixing coins.", "", sender: Wallet);
return;
}
finally
@@ -336,18 +336,18 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (compatiblityPasswordUsed != null)
{
Password = compatiblityPasswordUsed; // Overwrite the password for BuildTransaction function.
- NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage);
+ NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage, sender: Wallet);
}
}
catch (SecurityException ex)
{
- NotificationHelpers.Error(ex.Message, "");
+ NotificationHelpers.Error(ex.Message, "", sender: Wallet);
return;
}
catch (Exception ex)
{
Logger.LogError(ex);
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: Wallet);
return;
}
}
@@ -359,16 +359,16 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
catch (InsufficientBalanceException ex)
{
Money needed = ex.Minimum - ex.Actual;
- NotificationHelpers.Error($"Not enough coins selected. You need an estimated {needed.ToString(false, true)} BTC more to make this transaction.", "");
+ NotificationHelpers.Error($"Not enough coins selected. You need an estimated {needed.ToString(false, true)} BTC more to make this transaction.", "", sender: Wallet);
}
catch (HttpRequestException ex)
{
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: Wallet);
Logger.LogError(ex);
}
catch (Exception ex)
{
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: Wallet);
Logger.LogError(ex);
}
finally
@@ -411,14 +411,14 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(ex =>
{
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: Wallet);
Logger.LogError(ex);
});
}
protected Global Global { get; }
- private Wallet Wallet { get; }
+ public Wallet Wallet { get; }
Wallet IWalletViewModel.Wallet => Wallet;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -17,14 +17,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public SendTabViewModel(Wallet wallet) : base(wallet, "Send")
{
- Wallet = wallet;
}
public override string DoButtonText => "Send Transaction";
public override string DoingButtonText => "Sending Transaction...";
- private Wallet Wallet { get; }
-
protected override async Task DoAfterBuildTransaction(BuildTransactionResult result)
{
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusType.SigningTransaction);
@@ -53,7 +50,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: Wallet);
return;
}
finally

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -47,7 +47,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (isCompatibilityPasswordUsed != null)
{
- NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage);
+ NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage, sender: Wallet);
}
string master = secret.GetWif(Global.Network).ToWif();
@@ -62,7 +62,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(ex =>
{
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: wallet);
Logger.LogError(ex);
});
}

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -459,7 +459,7 @@ namespace WalletWasabi.Gui
var type = reason == DequeueReason.UserRequested ? NotificationType.Information : NotificationType.Warning;
var message = reason == DequeueReason.UserRequested ? "" : reason.ToFriendlyString();
var title = success.Value.Count() == 1 ? $"Coin ({success.Value.First().Amount.ToString(false, true)}) Dequeued" : $"{success.Value.Count()} Coins Dequeued";
- NotificationHelpers.Notify(message, title, type);
+ NotificationHelpers.Notify(message, title, type, sender: sender);
}
}
@@ -469,7 +469,7 @@ namespace WalletWasabi.Gui
var type = NotificationType.Warning;
var message = reason.ToFriendlyString();
var title = failure.Value.Count() == 1 ? $"Couldn't Dequeue Coin ({failure.Value.First().Amount.ToString(false, true)})" : $"Couldn't Dequeue {failure.Value.Count()} Coins";
- NotificationHelpers.Notify(message, title, type);
+ NotificationHelpers.Notify(message, title, type, sender: sender);
}
}
catch (Exception ex)
@@ -509,38 +509,38 @@ namespace WalletWasabi.Gui
if (e.Transaction.Transaction.IsCoinBase)
{
- NotifyAndLog($"{amountString} BTC", "Mined", NotificationType.Success, e);
+ NotifyAndLog($"{amountString} BTC", "Mined", NotificationType.Success, e, sender);
}
else if (isSpent && receiveSpentDiff == miningFee)
{
- NotifyAndLog($"Mining Fee: {amountString} BTC", "Self Spend", NotificationType.Information, e);
+ NotifyAndLog($"Mining Fee: {amountString} BTC", "Self Spend", NotificationType.Information, e, sender);
}
else if (isSpent && receiveSpentDiff.Almost(Money.Zero, Money.Coins(0.01m)) && e.IsLikelyOwnCoinJoin)
{
- NotifyAndLog($"CoinJoin Completed!", "", NotificationType.Success, e);
+ NotifyAndLog($"CoinJoin Completed!", "", NotificationType.Success, e, sender);
}
else if (incoming > Money.Zero)
{
if (e.Transaction.IsRBF && e.Transaction.IsReplacement)
{
- NotifyAndLog($"{amountString} BTC", "Received Replaceable Replacement Transaction", NotificationType.Information, e);
+ NotifyAndLog($"{amountString} BTC", "Received Replaceable Replacement Transaction", NotificationType.Information, e, sender);
}
else if (e.Transaction.IsRBF)
{
- NotifyAndLog($"{amountString} BTC", "Received Replaceable Transaction", NotificationType.Success, e);
+ NotifyAndLog($"{amountString} BTC", "Received Replaceable Transaction", NotificationType.Success, e, sender);
}
else if (e.Transaction.IsReplacement)
{
- NotifyAndLog($"{amountString} BTC", "Received Replacement Transaction", NotificationType.Information, e);
+ NotifyAndLog($"{amountString} BTC", "Received Replacement Transaction", NotificationType.Information, e, sender);
}
else
{
- NotifyAndLog($"{amountString} BTC", "Received", NotificationType.Success, e);
+ NotifyAndLog($"{amountString} BTC", "Received", NotificationType.Success, e, sender);
}
}
else if (incoming < Money.Zero)
{
- NotifyAndLog($"{amountString} BTC", "Sent", NotificationType.Information, e);
+ NotifyAndLog($"{amountString} BTC", "Sent", NotificationType.Information, e, sender);
}
}
else if (isConfirmedReceive || isConfirmedSpent)
@@ -553,19 +553,19 @@ namespace WalletWasabi.Gui
if (isConfirmedSpent && receiveSpentDiff == miningFee)
{
- NotifyAndLog($"Mining Fee: {amountString} BTC", "Self Spend Confirmed", NotificationType.Information, e);
+ NotifyAndLog($"Mining Fee: {amountString} BTC", "Self Spend Confirmed", NotificationType.Information, e, sender);
}
else if (isConfirmedSpent && receiveSpentDiff.Almost(Money.Zero, Money.Coins(0.01m)) && e.IsLikelyOwnCoinJoin)
{
- NotifyAndLog($"CoinJoin Confirmed!", "", NotificationType.Information, e);
+ NotifyAndLog($"CoinJoin Confirmed!", "", NotificationType.Information, e, sender);
}
else if (incoming > Money.Zero)
{
- NotifyAndLog($"{amountString} BTC", "Receive Confirmed", NotificationType.Information, e);
+ NotifyAndLog($"{amountString} BTC", "Receive Confirmed", NotificationType.Information, e, sender);
}
else if (incoming < Money.Zero)
{
- NotifyAndLog($"{amountString} BTC", "Send Confirmed", NotificationType.Information, e);
+ NotifyAndLog($"{amountString} BTC", "Send Confirmed", NotificationType.Information, e, sender);
}
}
}
@@ -586,11 +586,11 @@ namespace WalletWasabi.Gui
return !StoppingCts.IsCancellationRequested;
}
- private static void NotifyAndLog(string message, string title, NotificationType notificationType, ProcessedResult e)
+ private static void NotifyAndLog(string message, string title, NotificationType notificationType, ProcessedResult e, object sender)
{
message = Guard.Correct(message);
title = Guard.Correct(title);
- NotificationHelpers.Notify(message, title, notificationType, async () => await FileHelpers.OpenFileInTextEditorAsync(Logger.FilePath));
+ NotificationHelpers.Notify(message, title, notificationType, async () => await FileHelpers.OpenFileInTextEditorAsync(Logger.FilePath), sender);
Logger.LogInfo($"Transaction Notification ({notificationType}): {title} - {message} - {e.Transaction.GetHash()}");
}

MODIFY
WalletWasabi.Gui/Helpers/NotificationHelpers.cs
WalletWasabi.Gui/Helpers/NotificationHelpers.cs
@@ -3,6 +3,8 @@ using ReactiveUI;
using Splat;
using System;
using System.Reactive.Concurrency;
+using WalletWasabi.Gui.Controls.WalletExplorer;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Helpers
{
@@ -15,39 +17,40 @@ namespace WalletWasabi.Gui.Helpers
return Locator.Current.GetService<INotificationManager>() ?? NullNotificationManager;
}
- public static void Notify(string message, string title, NotificationType type, Action onClick = null)
+ public static void Notify(string message, string title, NotificationType type, Action onClick = null, object sender = null)
{
+ if (sender is Wallet wallet)
+ {
+ title = $"{title} - {wallet.WalletName}";
+ }
+ else if (sender is WalletViewModelBase walletViewModelBase)
+ {
+ title = $"{title} - {walletViewModelBase.WalletName}";
+ }
+
RxApp.MainThreadScheduler
.Schedule(() => GetNotificationManager()
.Show(new Notification(title, message, type, TimeSpan.FromSeconds(7), onClick)));
}
- public static void Success(string message, string title = "Success!")
+ public static void Success(string message, string title = "Success!", object sender = null)
{
- RxApp.MainThreadScheduler
- .Schedule(() => GetNotificationManager()
- .Show(new Notification(title, message, NotificationType.Success, TimeSpan.FromSeconds(7))));
+ Notify(message, title, NotificationType.Success, sender: sender);
}
- public static void Information(string message, string title = "Info")
+ public static void Information(string message, string title = "Info", object sender = null)
{
- RxApp.MainThreadScheduler
- .Schedule(() => GetNotificationManager()
- .Show(new Notification(title, message, NotificationType.Information, TimeSpan.FromSeconds(7))));
+ Notify(message, title, NotificationType.Information, sender: sender);
}
- public static void Warning(string message, string title = "Warning!")
+ public static void Warning(string message, string title = "Warning!", object sender = null)
{
- RxApp.MainThreadScheduler
- .Schedule(() => GetNotificationManager()
- .Show(new Notification(title, message, NotificationType.Warning, TimeSpan.FromSeconds(7))));
+ Notify(message, title, NotificationType.Warning, sender: sender);
}
- public static void Error(string message, string title = "Error!")
+ public static void Error(string message, string title = "Error!", object sender = null)
{
- RxApp.MainThreadScheduler
- .Schedule(() => GetNotificationManager()
- .Show(new Notification(title, message, NotificationType.Error, TimeSpan.FromSeconds(7))));
+ Notify(message, title, NotificationType.Error, sender: sender);
}
}
}

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWallets/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWallets/LoadWalletViewModel.cs
@@ -156,10 +156,10 @@ namespace WalletWasabi.Gui.Tabs.WalletManager.LoadWallets
{
if (PasswordHelper.TryPassword(keyManager, password, out string compatibilityPasswordUsed))
{
- NotificationHelpers.Success("Correct password.");
+ NotificationHelpers.Success("Correct password.", sender: selectedWallet);
if (compatibilityPasswordUsed != null)
{
- NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage);
+ NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage, sender: selectedWallet);
}
keyManager.SetPasswordVerified();

MODIFY
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
@@ -149,7 +149,7 @@ namespace WalletWasabi.Gui.ViewModels
.Subscribe(ex =>
{
Logger.LogError(ex);
- NotificationHelpers.Error(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString(), sender: owner.Wallet);
});
}

Add WalletName to Notifications