PasswordHelper: Fix a few warnings.
MODIFY
WalletWasabi.Tests/UnitTests/Userfacing/PasswordTests.cs
WalletWasabi.Tests/UnitTests/Userfacing/PasswordTests.cs
@@ -72,12 +72,12 @@ namespace WalletWasabi.Tests.UnitTests
Assert.True(PasswordHelper.IsTrimmable(badPassword, out badPassword));
// Still too long.
- Assert.Throws<FormatException>(() => PasswordHelper.GetMasterExtKey(keyManager, badPassword, out _));
+ Assert.Throws<FormatException>(() => PasswordHelper.GetMasterExtKey(keyManager, badPassword!, out _));
Assert.True(PasswordHelper.IsTooLong(badPassword, out badPassword));
// This should not throw format exception but pw is not correct.
- Assert.Throws<SecurityException>(() => PasswordHelper.GetMasterExtKey(keyManager, badPassword, out _));
+ Assert.Throws<SecurityException>(() => PasswordHelper.GetMasterExtKey(keyManager, badPassword!, out _));
Logger.TurnOn();
}
@@ -101,12 +101,12 @@ namespace WalletWasabi.Tests.UnitTests
Assert.False(PasswordHelper.TryPassword(keyManager, "falsepassword", out _));
// This should pass
- Assert.NotNull(PasswordHelper.GetMasterExtKey(keyManager, original, out _));
+ Assert.NotNull(PasswordHelper.GetMasterExtKey(keyManager, original!, out _));
Assert.True(PasswordHelper.TryPassword(keyManager, buggy, out var compatiblePasswordNotUsed));
Assert.Null(compatiblePasswordNotUsed);
- Assert.True(PasswordHelper.TryPassword(keyManager, original, out var compatiblePassword));
+ Assert.True(PasswordHelper.TryPassword(keyManager, original!, out var compatiblePassword));
Assert.Equal(buggy, compatiblePassword);
Logger.TurnOn();
}

MODIFY
WalletWasabi/Userfacing/PasswordHelper.cs
WalletWasabi/Userfacing/PasswordHelper.cs
@@ -19,7 +19,7 @@ namespace WalletWasabi.Userfacing
public const string MatchingMessage = "Passwords don't match, check any spelling mistakes and try again.";
public const string WhitespaceMessage = "Leading and trailing white spaces are not allowed!";
- public static string[] GetPossiblePasswords(string originalPassword)
+ public static string[] GetPossiblePasswords(string? originalPassword)
{
if (string.IsNullOrEmpty(originalPassword))
{
@@ -125,7 +125,7 @@ namespace WalletWasabi.Userfacing
ExtKey result = keyManager.GetMasterExtKey(pw);
// Now the password is OK but if we had SecurityException before then we used a compatibility password.
- if (resultException is { })
+ if (resultException is not null)
{
compatiblityPassword = pw;
Logger.LogError(CompatibilityPasswordWarnMessage);

PasswordHelper: Fix a few warnings.