Use the Kitchen
MODIFY
WalletWasabi.Fluent/ViewModels/Login/LoginViewModel.cs
WalletWasabi.Fluent/ViewModels/Login/LoginViewModel.cs
@@ -49,7 +49,7 @@ namespace WalletWasabi.Fluent.ViewModels.Login
if (!IsPasswordIncorrect)
{
- wallet.Login();
+ wallet.Login(Password);
walletViewModelBase.RaisePropertyChanged(nameof(WalletViewModelBase.IsLoggedIn));
// TODO: navigate to the wallet welcome page

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -782,8 +782,6 @@ namespace WalletWasabi.CoinJoin.Client.Clients
var coinsExcept = coins.Except(except);
var secPubs = KeyManager.GetSecretsAndPubKeyPairs(password, coinsExcept.Select(x => x.ScriptPubKey).ToArray());
- Kitchen.Cook(password);
-
foreach (SmartCoin coin in coinsExcept)
{
coin.Secret = secPubs.Single(x => x.pubKey.P2wpkhScript == coin.ScriptPubKey).secret;

MODIFY
WalletWasabi/Wallets/Kitchen.cs
WalletWasabi/Wallets/Kitchen.cs
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,17 +11,18 @@ namespace WalletWasabi.Wallets
{
public class Kitchen
{
- private string Salt { get; set; } = null;
- private string Soup { get; set; } = null;
+ private string? Salt { get; set; } = null;
+ private string? Soup { get; set; } = null;
private object RefrigeratorLock { get; } = new object();
+ [MemberNotNullWhen(returnValue: true, nameof(Salt), nameof(Soup))]
public bool HasIngredients => Salt is { } && Soup is { };
public string SaltSoup()
{
if (!HasIngredients)
{
- return "";
+ throw new InvalidOperationException("Ingredients are missing.");
}
string res;
@@ -44,5 +46,14 @@ namespace WalletWasabi.Wallets
Soup = StringCipher.Encrypt(ingredients, Salt);
}
}
+
+ public void CleanUp()
+ {
+ lock (RefrigeratorLock)
+ {
+ Salt = null;
+ Soup = null;
+ }
+ }
}
}

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -93,13 +93,19 @@ namespace WalletWasabi.Wallets
public IBlockProvider BlockProvider { get; private set; }
private AsyncLock HandleFiltersLock { get; }
- public bool IsLoggedIn { get; private set; }
+ public bool IsLoggedIn => Kitchen.HasIngredients;
private Kitchen Kitchen { get; } = new();
- public void Login() => IsLoggedIn = true;
+ public void Login(string password)
+ {
+ Kitchen.Cook(password);
+ }
- public void Logout() => IsLoggedIn = false;
+ public void Logout()
+ {
+ Kitchen.CleanUp();
+ }
public void RegisterServices(
BitcoinStore bitcoinStore,

Use the Kitchen