Validate change and active addresses
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -791,31 +791,52 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _password, value);
}
- public ErrorDescriptors ValidateAddress() => ValidateAddress(Address);
+ public ErrorDescriptors ValidateActiveAddress()
+ {
+ if (string.IsNullOrWhiteSpace(Address))
+ {
+ return ErrorDescriptors.Empty;
+ }
- public ErrorDescriptors ValidateCustomChangeAddress() => ValidateAddress(CustomChangeAddress);
+ if (Address.Trim() == CustomChangeAddress?.Trim())
+ {
+ return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Error, "Active and change addresses cannot be the same."));
+ }
- private ErrorDescriptors ValidateAddress(string address)
+ if (AddressStringParser.TryParseBitcoinAddress(Address, Global.Network, out _))
{
- if (string.IsNullOrWhiteSpace(address))
+ return ErrorDescriptors.Empty;
+ }
+
+ if (AddressStringParser.TryParseBitcoinUrl(Address, Global.Network, out _))
{
return ErrorDescriptors.Empty;
}
- if (AddressStringParser.TryParseBitcoinAddress(address, Global.Network, out _))
+ return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Error, "Invalid address."));
+ }
+
+ public ErrorDescriptors ValidateCustomChangeAddress()
+ {
+ if (string.IsNullOrWhiteSpace(CustomChangeAddress))
{
return ErrorDescriptors.Empty;
}
- if (AddressStringParser.TryParseBitcoinUrl(address, Global.Network, out _))
+ if (Address?.Trim() == CustomChangeAddress.Trim())
+ {
+ return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Error, "Active and change addresses cannot be the same."));
+ }
+
+ if (AddressStringParser.TryParseBitcoinAddress(CustomChangeAddress, Global.Network, out _))
{
return ErrorDescriptors.Empty;
}
- return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Error, "Invalid address."));
+ return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Error, "Invalid change address."));
}
- [ValidateMethod(nameof(ValidateAddress))]
+ [ValidateMethod(nameof(ValidateActiveAddress))]
public string Address
{
get => _address;

MODIFY
WalletWasabi.Gui/ViewModels/Validation/ValidateMethodAttribute.cs
WalletWasabi.Gui/ViewModels/Validation/ValidateMethodAttribute.cs
@@ -4,7 +4,7 @@ using System.Text;
namespace WalletWasabi.Gui.ViewModels.Validation
{
- [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
+ [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
public sealed class ValidateMethodAttribute : Attribute
{
public ValidateMethodAttribute(string methodName)

Validate change and active addresses