Close wallet manager on successful wallet load
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -140,6 +140,23 @@ namespace WalletWasabi.Gui
CancelWalletServiceInitialization = null; // Must make it null explicitly, because dispose won't make it null.
}
+ public static async Task DisposeInWalletDependentServicesAsync()
+ {
+ CancelWalletServiceInitialization?.Cancel();
+ CancelWalletServiceInitialization = null;
+
+ WalletService?.Dispose();
+ WalletService = null;
+ Logger.LogInfo($"{nameof(WalletService)} is stopped.", nameof(Global));
+
+ if (ChaumianClient != null)
+ {
+ await ChaumianClient.StopAsync();
+ ChaumianClient = null;
+ }
+ Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.", nameof(Global));
+ }
+
public static async Task DisposeAsync()
{
CancelWalletServiceInitialization?.Cancel();

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/LoadWalletViewModel.cs
@@ -18,15 +18,14 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
{
private ObservableCollection<string> _wallets;
private string _selectedWallet;
- private bool _isSelectedWallet;
private bool _isWalletOpened;
private bool _canLoadWallet;
private string _warningMessage;
- private WalletManagerViewModel _owner;
+ private WalletManagerViewModel Owner { get; }
public LoadWalletViewModel(WalletManagerViewModel owner) : base("Load Wallet")
{
- _owner = owner;
+ Owner = owner;
_wallets = new ObservableCollection<string>();
this.WhenAnyValue(x => x.SelectedWallet)
@@ -105,11 +104,21 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
return;
}
+ try
+ {
var keyManager = KeyManager.FromFile(walletFullPath);
-
await Global.InitializeWalletServiceAsync(keyManager);
-
- // ToDo: Close the Wallet Manager, Open Wallet Explorer tabs
+ // Successffully initialized.
+ IoC.Get<IShell>().RemoveDocument(Owner);
+ // ToDo: Open Wallet Explorer tabs
+ }
+ catch (Exception ex)
+ {
+ // Initialization failed.
+ // ToDo: Show error messages.
+ Logger.LogError<LoadWalletViewModel>(ex);
+ await Global.DisposeInWalletDependentServicesAsync();
+ }
}
}
}

Close wallet manager on successful wallet load