Store MasterKey instead of Decrypt every time
MODIFY
WalletWasabi/WabiSabi/Client/KeyChain.cs
WalletWasabi/WabiSabi/Client/KeyChain.cs
@@ -3,6 +3,7 @@ using NBitcoin;
using System.Linq;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Wallets;
+using System.Diagnostics.CodeAnalysis;
namespace WalletWasabi.WabiSabi.Client;
@@ -18,10 +19,21 @@ public class KeyChain : BaseKeyChain
}
private KeyManager KeyManager { get; }
+ private ExtKey? MasterKey { get; set; }
+
+ [MemberNotNull(nameof(MasterKey))]
+ public void PreloadMasterKey()
+ {
+ MasterKey = KeyManager.GetMasterExtKey(Kitchen.SaltSoup());
+ }
protected override Key GetMasterKey()
{
- return KeyManager.GetMasterExtKey(Kitchen.SaltSoup()).PrivateKey;
+ if (MasterKey is null)
+ {
+ PreloadMasterKey();
+ }
+ return MasterKey.PrivateKey;
}
public override void TrySetScriptStates(KeyState state, IEnumerable<Script> scripts)

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -154,6 +154,11 @@ public class Wallet : BackgroundService, IWallet
Kitchen.Cook(compatibilityPasswordUsed ?? Guard.Correct(password));
}
+ if (IsLoggedIn && KeyChain is KeyChain keychain)
+ {
+ keychain.PreloadMasterKey();
+ }
+
return IsLoggedIn;
}

Store MasterKey instead of Decrypt every time