AddressStringParser null checks
MODIFY
WalletWasabi/Helpers/AddressStringParser.cs
WalletWasabi/Helpers/AddressStringParser.cs
@@ -12,13 +12,13 @@ namespace WalletWasabi.Helpers
{
url = null;
- text = text.Trim();
-
- if (text is null || text.Length > 100 || text.Length < 20)
+ if (text is null || text.Length > 100 || text.Length < 20 || expectedNetwork is null)
{
return false;
}
+ text = text.Trim();
+
try
{
var bitcoinAddress = BitcoinAddress.Create(text, expectedNetwork);
@@ -35,17 +35,17 @@ namespace WalletWasabi.Helpers
{
url = null;
- text = text.Trim();
-
- if (text is null || text.Length > 1000 || text.Length < 20)
+ if (text is null || text.Length > 1000 || text.Length < 20 || expectedNetwork is null)
{
return false;
}
+ text = text.Trim();
+
try
{
var bitcoinUrl = new BitcoinUrlBuilder(text);
- if (bitcoinUrl.Address.Network == expectedNetwork)
+ if (bitcoinUrl?.Address.Network == expectedNetwork)
{
url = bitcoinUrl;
return true;

AddressStringParser null checks