Force users to verify their wallet password
MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -252,6 +252,11 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
KeyManager keyManager = Global.LoadKeyManager(walletFullPath, walletBackupFullPath);
+ if(!requirePassword && keyManager.PasswordVerified == false)
+ {
+ Owner.SelectTestPassword();
+ return null;
+ }
// Only check requirepassword here, because the above checks are applicable to loadwallet, too and we are using this function from load wallet.
if (requirePassword)
{
@@ -263,6 +268,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
else
{
SetSuccessMessage("Correct password.");
+ keyManager.SetPasswordVerified();
}
}

MODIFY
WalletWasabi.Tests/KeyManagementTests.cs
WalletWasabi.Tests/KeyManagementTests.cs
@@ -42,7 +42,7 @@ namespace WalletWasabi.Tests
Assert.NotNull(manager3.EncryptedSecret);
Assert.NotNull(manager3.ExtPubKey);
- var sameManager = new KeyManager(manager.EncryptedSecret, manager.ChainCode, manager.ExtPubKey);
+ var sameManager = new KeyManager(manager.EncryptedSecret, manager.ChainCode, manager.ExtPubKey, true);
var sameManager2 = new KeyManager(manager.EncryptedSecret, manager.ChainCode, password);
Logger.TurnOff();
Assert.Throws<SecurityException>(() => new KeyManager(manager.EncryptedSecret, manager.ChainCode, "differentPassword"));

MODIFY
WalletWasabi/KeyManagement/KeyManager.cs
WalletWasabi/KeyManagement/KeyManager.cs
@@ -47,8 +47,11 @@ namespace WalletWasabi.KeyManagement
public string FilePath { get; private set; }
private object ToFileLock { get; }
+ [JsonProperty(Order = 5)]
+ public bool? PasswordVerified { get; private set; }
+
[JsonConstructor]
- public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, ExtPubKey extPubKey, string filePath = null)
+ public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, ExtPubKey extPubKey, bool? passwordVerified, string filePath = null)
{
HdPubKeys = new List<HdPubKey>();
HdPubKeyScriptBytes = new List<byte[]>();
@@ -60,6 +63,9 @@ namespace WalletWasabi.KeyManagement
EncryptedSecret = Guard.NotNull(nameof(encryptedSecret), encryptedSecret);
ChainCode = Guard.NotNull(nameof(chainCode), chainCode);
ExtPubKey = Guard.NotNull(nameof(extPubKey), extPubKey);
+
+ PasswordVerified = passwordVerified;
+
SetFilePath(filePath);
ToFileLock = new object();
ToFile();
@@ -101,7 +107,7 @@ namespace WalletWasabi.KeyManagement
ExtKey extKey = mnemonic.DeriveExtKey(password);
var encryptedSecret = extKey.PrivateKey.GetEncryptedBitcoinSecret(password, Network.Main);
- return new KeyManager(encryptedSecret, extKey.ChainCode, extKey.Derive(AccountKeyPath).Neuter(), filePath);
+ return new KeyManager(encryptedSecret, extKey.ChainCode, extKey.Derive(AccountKeyPath).Neuter(), false, filePath);
}
public static KeyManager Recover(Mnemonic mnemonic, string password, string filePath = null)
@@ -115,7 +121,7 @@ namespace WalletWasabi.KeyManagement
ExtKey extKey = mnemonic.DeriveExtKey(password);
var encryptedSecret = extKey.PrivateKey.GetEncryptedBitcoinSecret(password, Network.Main);
- return new KeyManager(encryptedSecret, extKey.ChainCode, extKey.Derive(AccountKeyPath).Neuter(), filePath);
+ return new KeyManager(encryptedSecret, extKey.ChainCode, extKey.Derive(AccountKeyPath).Neuter(), true, filePath);
}
public void SetFilePath(string filePath)
@@ -250,6 +256,12 @@ namespace WalletWasabi.KeyManagement
}
}
+ public void SetPasswordVerified()
+ {
+ PasswordVerified = true;
+ ToFile();
+ }
+
public IEnumerable<HdPubKey> GetKeys(KeyState? keyState = null, bool? isInternal = null)
{
if (keyState is null && isInternal is null)

Force users to verify their wallet password