Move TryParse
MODIFY
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
@@ -60,34 +60,9 @@ namespace WalletWasabi.Gui.Behaviors
private TextBoxState _textBoxState = TextBoxState.None;
- private bool TryParse(string text, out BitcoinUrlBuilder result)
- {
- result = null;
- if (string.IsNullOrWhiteSpace(text) || text.Length > 1000)
- {
- return false;
- }
-
- text = text.Trim();
- if (AddressStringParser.TryParseBitcoinAddress(text, Global.Network, out BitcoinUrlBuilder addressResult))
- {
- result = addressResult;
- return true;
- }
- else
- {
- if (AddressStringParser.TryParseBitcoinUrl(text, Global.Network, out BitcoinUrlBuilder urlResult))
- {
- result = urlResult;
- return true;
- }
- }
- return false;
- }
-
private bool ProcessText(string text)
{
- if (TryParse(text, out BitcoinUrlBuilder result))
+ if (AddressStringParser.TryParse(text, Global.Network, out BitcoinUrlBuilder result))
{
AssociatedObject.Text = result?.Address?.ToString();
CommandParameter = result;
@@ -189,7 +164,7 @@ namespace WalletWasabi.Gui.Behaviors
{
string text = await Application.Current.Clipboard.GetTextAsync();
- if (TryParse(text, out _))
+ if (AddressStringParser.TryParse(text, Global.Network, out _))
{
MyTextBoxState = TextBoxState.AddressInsert;
}

MODIFY
WalletWasabi/Helpers/AddressStringParser.cs
WalletWasabi/Helpers/AddressStringParser.cs
@@ -73,5 +73,29 @@ namespace WalletWasabi.Helpers
return false;
}
}
+
+ public static bool TryParse(string text, Network expectedNetwork, out BitcoinUrlBuilder result)
+ {
+ result = null;
+ if (string.IsNullOrWhiteSpace(text) || text.Length > 1000)
+ {
+ return false;
+ }
+
+ if (TryParseBitcoinAddress(text, expectedNetwork, out BitcoinUrlBuilder addressResult))
+ {
+ result = addressResult;
+ return true;
+ }
+ else
+ {
+ if (TryParseBitcoinUrl(text, expectedNetwork, out BitcoinUrlBuilder urlResult))
+ {
+ result = urlResult;
+ return true;
+ }
+ }
+ return false;
+ }
}
}

Move TryParse