simplify wallet exist check
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/HardwareWalletOperations.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/HardwareWalletOperations.cs
@@ -143,8 +143,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
var detectedHardwareWallets =
(await Client.EnumerateAsync(timeoutCts.Token)
.ConfigureAwait(false))
- .Where(wallet => WalletManager.GetWallets()
- .Any(x => x.KeyManager.MasterFingerprint == wallet.Fingerprint) == false)
+ .Where(wallet => !WalletManager.IsWalletExists(wallet.Fingerprint))
.ToArray();
detectionCts.Token.ThrowIfCancellationRequested();

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/ImportWalletHelper.cs
WalletWasabi.Fluent/ViewModels/AddWallet/ImportWalletHelper.cs
@@ -40,13 +40,11 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
return (isColdcardJson, km);
}
- private static bool IsWalletExists(WalletManager manager, HDFingerprint? fingerprint) => manager.GetWallets().Any(x => fingerprint is { } && x.KeyManager.MasterFingerprint == fingerprint);
-
private static KeyManager GetKeyManagerByWasabiJson(WalletManager manager, string filePath, string walletFullPath)
{
var km = KeyManager.FromFile(filePath);
- if (IsWalletExists(manager, km.MasterFingerprint))
+ if (manager.IsWalletExists(km.MasterFingerprint))
{
throw new InvalidOperationException(_walletExistsErrorMessage);
}
@@ -83,7 +81,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
var bytes = ByteHelpers.FromHex(Guard.NotNullOrEmptyOrWhitespace(nameof(mfpString), mfpString, trim: true));
HDFingerprint mfp = reverseByteOrder ? new HDFingerprint(bytes.Reverse().ToArray()) : new HDFingerprint(bytes);
- if (IsWalletExists(manager, mfp))
+ if (manager.IsWalletExists(mfp))
{
throw new InvalidOperationException(_walletExistsErrorMessage);
}

MODIFY
WalletWasabi/Wallets/WalletManager.cs
WalletWasabi/Wallets/WalletManager.cs
@@ -276,6 +276,8 @@ namespace WalletWasabi.Wallets
await Task.WhenAll(tasks).ConfigureAwait(false);
}
+ public bool IsWalletExists(HDFingerprint? fingerprint) => GetWallets().Any(x => fingerprint is { } && x.KeyManager.MasterFingerprint == fingerprint);
+
private void ChaumianClient_OnDequeue(object? sender, DequeueResult e)
{
OnDequeue?.Invoke(sender, e);

simplify wallet exist check