Improve notifications
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -186,7 +186,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!selectedCoins.Any())
{
- NotificationHelpers.Error("No coins are selected to dequeue.");
+ NotificationHelpers.Warning("No coins are selected.", "");
return;
}
@@ -221,7 +221,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!selectedCoins.Any())
{
- NotificationHelpers.Error("No coins are selected to enqueue.");
+ NotificationHelpers.Warning("No coins are selected.", "");
return;
}
try
@@ -238,7 +238,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (SecurityException ex)
{
- NotificationHelpers.Error(ex.Message);
+ NotificationHelpers.Error(ex.Message, "");
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -234,7 +234,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
_labelSuggestion.Label = label;
if (!IsMax && label.IsEmpty)
{
- NotificationHelpers.Error($"{nameof(_labelSuggestion.Label)} is required.");
+ NotificationHelpers.Warning($"{nameof(_labelSuggestion.Label)} is required.", "");
return;
}
@@ -243,7 +243,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (!selectedCoinReferences.Any())
{
- NotificationHelpers.Error("No coins are selected to spend.");
+ NotificationHelpers.Warning("No coins are selected to spend.", "");
return;
}
@@ -254,7 +254,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (FormatException)
{
- NotificationHelpers.Error("Invalid address.");
+ NotificationHelpers.Warning("Invalid address.", "");
return;
}
@@ -267,13 +267,13 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!Money.TryParse(AmountText, out Money amount) || amount == Money.Zero)
{
- NotificationHelpers.Error("Invalid amount.");
+ NotificationHelpers.Warning("Invalid amount.");
return;
}
if (amount == selectedCoinViewModels.Sum(x => x.Amount))
{
- NotificationHelpers.Error("Looks like you want to spend a whole coin. Try Max button instead.");
+ NotificationHelpers.Warning("Looks like you want to spend whole coins. Try Max button instead.", "");
return;
}
moneyRequest = MoneyRequest.Create(amount);
@@ -281,7 +281,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (FeeRate is null || FeeRate.SatoshiPerByte < 1)
{
- NotificationHelpers.Error("Invalid fee rate, must be greater than or equal to one.");
+ NotificationHelpers.Warning("Invalid fee rate.", "");
return;
}
@@ -294,12 +294,14 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
TxoRef[] toDequeue = selectedCoinViewModels.Where(x => x.CoinJoinInProgress).Select(x => x.Model.GetTxoRef()).ToArray();
if (toDequeue != null && toDequeue.Any())
{
- await Global.ChaumianClient.DequeueCoinsFromMixAsync(toDequeue, "Coin is used in a spending transaction built by the user.");
+ var reason = "Coins dequeued, because of normal send.";
+ await Global.ChaumianClient.DequeueCoinsFromMixAsync(toDequeue, reason);
+ NotificationHelpers.Warning(reason, "");
}
}
catch
{
- NotificationHelpers.Error("Spending coins that are being actively mixed is not allowed.");
+ NotificationHelpers.Error("Cannot spend mixing coins.", "");
return;
}
finally
@@ -320,7 +322,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (SecurityException ex)
{
- NotificationHelpers.Error(ex.Message);
+ NotificationHelpers.Error(ex.Message, "");
return;
}
catch (Exception ex)
@@ -344,7 +346,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
txviewer.Update(result);
- TryResetInputsOnSuccess("Transaction is successfully built!");
+ ResetUi();
+
+ NotificationHelpers.Success("Transaction is successfully built!", "");
return;
}
@@ -388,12 +392,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusBarStatus.BroadcastingTransaction);
await Task.Run(async () => await Global.TransactionBroadcaster.SendTransactionAsync(signedTransaction));
- TryResetInputsOnSuccess("Transaction is successfully sent!");
+ ResetUi();
}
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.", "");
}
catch (HttpRequestException ex)
{
@@ -684,20 +688,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
}
- private void TryResetInputsOnSuccess(string successMessage)
- {
- try
- {
- ResetUi();
-
- NotificationHelpers.Success(successMessage);
- }
- catch (Exception ex)
- {
- Logger.LogInfo(ex);
- }
- }
-
public CoinListViewModel CoinList { get; }
public bool IsBusy

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Controls.Notifications;
using Avalonia.Threading;
using NBitcoin;
using NBitcoin.Protocol;
@@ -12,6 +13,7 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.BitcoinCore;
@@ -504,14 +506,20 @@ namespace WalletWasabi.Gui
// Received dust
// Received coinbase -> mined
// Tx confirmed
- // Log
- if (e.NewlyReceivedCoins.Any())
+ if (e.NewlyReceivedCoins.Any() || e.NewlySpentCoins.Any())
{
- Money satSum = e.NewlyReceivedCoins.Where(x => !x.HdPubKey.IsInternal).Sum(x => x.Amount);
- string amountString = satSum.ToString(false, true);
-
- NotificationHelpers.Information($"{amountString} BTC", "Received");
+ Money diff = e.NewlyReceivedCoins.Sum(x => x.Amount) - e.NewlySpentCoins.Sum(x => x.Amount);
+ var diffAbs = diff.Abs();
+ string amountString = diffAbs.ToString(false, true);
+ if (diff > Money.Zero)
+ {
+ NotifyAndLog($"{amountString} BTC", "Received", NotificationType.Information);
+ }
+ else if (diff < Money.Zero)
+ {
+ NotifyAndLog($"{amountString} BTC", "Sent", NotificationType.Information);
+ }
}
}
catch (Exception ex)
@@ -520,6 +528,14 @@ namespace WalletWasabi.Gui
}
}
+ private static void NotifyAndLog(string message, string title, NotificationType notificationType)
+ {
+ message = Guard.Correct(message);
+ title = Guard.Correct(title);
+ NotificationHelpers.Notify(message, title, notificationType, () => IoHelpers.OpenFileInTextEditor(Logger.FilePath));
+ Logger.LogInfo($"Notification ({notificationType}): {title} - {message}");
+ }
+
public string GetWalletFullPath(string walletName)
{
walletName = walletName.TrimEnd(".json", StringComparison.OrdinalIgnoreCase);

MODIFY
WalletWasabi.Gui/Helpers/NotificationHelpers.cs
WalletWasabi.Gui/Helpers/NotificationHelpers.cs
@@ -13,6 +13,13 @@ namespace WalletWasabi.Gui.Helpers
return Locator.Current.GetService<INotificationManager>();
}
+ public static void Notify(string message, string title, NotificationType type, Action onClick = null)
+ {
+ RxApp.MainThreadScheduler
+ .Schedule(() => GetNotificationManager()
+ .Show(new Notification(title, message, type, TimeSpan.FromSeconds(7), onClick)));
+ }
+
public static void Success(string message, string title = "Success!")
{
RxApp.MainThreadScheduler

Improve notifications