Add pw compatibility.
RENAME
WalletWasabi.Gui/Helpers/PasswordHelper.cs
WalletWasabi/Helpers/PasswordHelper.cs
@@ -4,15 +4,16 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
-namespace WalletWasabi.Gui.Helpers
+namespace WalletWasabi.Helpers
{
public static class PasswordHelper
{
- public static string[] GetPossibleCompatiblityPasswords(string text)
+ public static string[] GetPossiblePasswords(string originalPassword)
{
List<string> possiblePasswords = new List<string>()
{
- StringCutIssue(text)
+ originalPassword,
+ StringCutIssue(originalPassword)
};
return possiblePasswords.ToArray();

MODIFY
WalletWasabi/KeyManagement/KeyManager.cs
WalletWasabi/KeyManagement/KeyManager.cs
@@ -76,6 +76,8 @@ namespace WalletWasabi.KeyManagement
public const int AbsoluteMinGapLimit = 21;
+ public bool IsCompatibilityPasswordUsed { get; private set; }
+
[JsonConstructor]
public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, HDFingerprint? masterFingerprint, ExtPubKey extPubKey, bool? passwordVerified, int? minGapLimit, BlockchainState blockchainState, string filePath = null, KeyPath accountKeyPath = null)
{
@@ -552,6 +554,7 @@ namespace WalletWasabi.KeyManagement
public ExtKey GetMasterExtKey(string password)
{
+ IsCompatibilityPasswordUsed = false;
if (password is null)
{
password = "";
@@ -562,9 +565,14 @@ namespace WalletWasabi.KeyManagement
throw new SecurityException("This is a watchonly wallet.");
}
+ Exception resultException = null;
+
+ foreach (var pw in PasswordHelper.GetPossiblePasswords(password))
+ {
try
{
- Key secret = EncryptedSecret.GetKey(password);
+ Key secret = EncryptedSecret.GetKey(pw);
+
var extKey = new ExtKey(secret, ChainCode);
// Backwards compatibility:
@@ -577,8 +585,13 @@ namespace WalletWasabi.KeyManagement
}
catch (SecurityException ex)
{
- throw new SecurityException("Invalid password.", ex);
+ resultException = ex;
+ }
+ IsCompatibilityPasswordUsed = true; // The first iteration will try the original password if we get here it was failed.
+ Logger.LogError<KeyManager>($"Compatibility password used! Please consider to generate a new wallet to ensure recovery of the wallet!");
}
+
+ throw new SecurityException("Invalid password.", resultException);
}
public bool TestPassword(string password)

Add pw compatibility.