implement validation
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -10,6 +10,7 @@ using NBitcoin;
using ReactiveUI;
using WalletWasabi.Models;
using WalletWasabi.Services;
+using WalletWasabi.Gui.ViewModels.Validation;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -82,24 +83,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
});
- this.WhenAnyValue(x => x.Address).Subscribe(x =>
- {
- if (!string.IsNullOrWhiteSpace(Address))
- {
- var trimmed = x.Trim();
- try
- {
- BitcoinAddress.Create(trimmed, Global.Network);
- }
- catch
- {
- // ToDo: Error out the textbox.
- return;
- }
- }
- // ToDo: Remove erroring out the textbox.
- });
-
BuildTransactionCommand = ReactiveCommand.Create(async () =>
{
IsBusy = true;
@@ -247,6 +230,30 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set { this.RaiseAndSetIfChanged(ref _password, value); }
}
+ public string ValidateAddress()
+ {
+ if (Address == string.Empty)
+ {
+ return "";
+ }
+
+ if (!string.IsNullOrWhiteSpace(Address))
+ {
+ var trimmed = Address.Trim();
+ try
+ {
+ BitcoinAddress.Create(trimmed, Global.Network);
+ return "";
+ }
+ catch
+ {
+ }
+ }
+
+ return "Please enter a valid Bitcoin Address";
+ }
+
+ [ValidateMethod(nameof(ValidateAddress))]
public string Address
{
get { return _address; }

implement validation