Optimize firststart
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -154,6 +154,16 @@ namespace WalletWasabi.Gui
TorManager = TorProcessManager.Mock();
}
TorManager.Start(false, DataDir);
+
+ try
+ {
+ await HwiProcessManager.EnsureHwiInstalledAsync(DataDir, Network);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, nameof(Global));
+ }
+
var fallbackRequestTestUri = new Uri(Config.GetFallbackBackendUri(), "/api/software/versions");
TorManager.StartMonitor(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(7), DataDir, fallbackRequestTestUri);
@@ -284,15 +294,6 @@ namespace WalletWasabi.Gui
Synchronizer.Start(requestInterval, TimeSpan.FromMinutes(5), maxFiltSyncCount);
Logger.LogInfo("Start synchronizing filters...");
-
- try
- {
- await HwiProcessManager.EnsureHwiInstalledAsync(DataDir, Network);
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, nameof(Global));
- }
}
private static CancellationTokenSource CancelWalletServiceInitialization = null;

MODIFY
WalletWasabi.Gui/MainWindow.xaml.cs
WalletWasabi.Gui/MainWindow.xaml.cs
@@ -172,33 +172,31 @@ namespace WalletWasabi.Gui
var walletManagerViewModel = new WalletManagerViewModel();
IoC.Get<IShell>().AddDocument(walletManagerViewModel);
- var isAnyHardwareWalletAvailable = false;
- try
+ var isAnyDesktopWalletAvailable = Directory.Exists(Global.WalletsDir) && Directory.EnumerateFiles(Global.WalletsDir).Any();
+
+ if (isAnyDesktopWalletAvailable)
{
- var res = await HwiProcessManager.EnumerateAsync();
- isAnyHardwareWalletAvailable = res.Any();
+ walletManagerViewModel.SelectLoadWallet();
}
- catch (Exception ex)
+ else
{
- Logging.Logger.LogWarning<MainWindow>(ex);
+ walletManagerViewModel.SelectGenerateWallet();
}
+ try
+ {
+ // Likely HwiProcessManager is not initialized at this point so make sure it is.
+ await HwiProcessManager.EnsureHwiInstalledAsync(Global.DataDir, Global.Network, logFound: false);
+ var res = await HwiProcessManager.EnumerateAsync();
+ var isAnyHardwareWalletAvailable = res.Any();
if (isAnyHardwareWalletAvailable)
{
walletManagerViewModel.SelectHardwareWallet();
}
- else
- {
- var isAnyDesktopWalletAvailable = Directory.Exists(Global.WalletsDir) && Directory.EnumerateFiles(Global.WalletsDir).Any();
-
- if (isAnyDesktopWalletAvailable)
- {
- walletManagerViewModel.SelectLoadWallet();
}
- else
+ catch (Exception ex)
{
- walletManagerViewModel.SelectGenerateWallet();
- }
+ Logging.Logger.LogWarning<MainWindow>(ex);
}
}
}

MODIFY
WalletWasabi/Hwi/HwiProcessManager.cs
WalletWasabi/Hwi/HwiProcessManager.cs
@@ -88,7 +88,8 @@ namespace WalletWasabi.Hwi
{
if (!File.Exists(HwiPath))
{
- throw new FileNotFoundException($"Hwi.exe not found here: {HwiPath}. Maybe it is removed by antivirus software!");
+ var exeName = Path.GetFileName(HwiPath);
+ throw new FileNotFoundException($"{exeName} not found at {HwiPath}. Maybe it was removed by antivirus software!");
}
using (var process = Process.Start(
@@ -160,7 +161,7 @@ namespace WalletWasabi.Hwi
}
}
- public static async Task EnsureHwiInstalledAsync(string dataDir, Network network)
+ public static async Task EnsureHwiInstalledAsync(string dataDir, Network network, bool logFound = true)
{
Network = network;
@@ -204,9 +205,12 @@ namespace WalletWasabi.Hwi
await InstallHwiAsync(fullBaseDirectory, hwiDir);
}
else
+ {
+ if (logFound)
{
Logger.LogInfo($"HWI instance found at {hwiPath}.", nameof(HwiProcessManager));
}
+ }
HwiPath = hwiPath;
}

Optimize firststart