existing wallet detection
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
using ReactiveUI;
using System;
+using System.Collections.ObjectModel;
using System.IO;
using System.Reactive.Disposables;
using System.Windows.Input;
@@ -16,6 +17,7 @@ using WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet;
using WalletWasabi.Gui.Validation;
using WalletWasabi.Models;
using WalletWasabi.Fluent.ViewModels.NavBar;
+using WalletWasabi.Fluent.ViewModels.Wallets;
using WalletWasabi.Helpers;
using WalletWasabi.Legal;
using WalletWasabi.Logging;
@@ -40,11 +42,11 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
private readonly LegalDocuments _legalDocuments;
- public AddWalletPageViewModel(
- LegalDocuments legalDocuments,
+ public AddWalletPageViewModel(LegalDocuments legalDocuments,
WalletManager walletManager,
BitcoinStore store,
- Network network)
+ Network network,
+ ObservableCollection<WalletViewModelBase> wallets)
{
Title = "Add Wallet";
SelectionMode = NavBarItemSelectionMode.Button;
@@ -93,7 +95,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
}
});
- ConnectHardwareWalletCommand = ReactiveCommand.Create(() => Navigate().To(new ConnectHardwareWalletViewModel(WalletName, walletManager)));
+ ConnectHardwareWalletCommand = ReactiveCommand.Create(() => Navigate().To(new ConnectHardwareWalletViewModel(WalletName, walletManager, wallets)));
CreateWalletCommand = ReactiveCommand.CreateFromTask(
async () =>

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/ConnectHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/ConnectHardwareWalletViewModel.cs
+using System.Collections.ObjectModel;
using System.IO;
+using System.Linq;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Input;
using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels.Login;
using WalletWasabi.Fluent.ViewModels.Navigation;
+using WalletWasabi.Fluent.ViewModels.Wallets;
using WalletWasabi.Hwi.Models;
using WalletWasabi.Wallets;
@@ -14,13 +18,15 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
{
[AutoNotify] private string _message;
[AutoNotify] private bool _isSearching;
+ [AutoNotify] private bool _existingWalletFound;
- public ConnectHardwareWalletViewModel(string walletName, WalletManager walletManager)
+ public ConnectHardwareWalletViewModel(string walletName, WalletManager walletManager, ObservableCollection<WalletViewModelBase> wallets)
{
Title = "Hardware Wallet";
_message = "";
WalletName = walletName;
WalletManager = walletManager;
+ Wallets = wallets;
HardwareWalletOperations = new HardwareWalletOperations(walletManager);
NextCommand = ReactiveCommand.Create(RunDetection);
@@ -28,19 +34,37 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
// TODO: Create an up-to-date article
OpenBrowserCommand = ReactiveCommand.CreateFromTask(async () =>
await IoHelpers.OpenBrowserAsync("https://docs.wasabiwallet.io/using-wasabi/ColdWasabi.html#using-hardware-wallet-step-by-step"));
+
+ NavigateToExistingWalletLoginCommand = ReactiveCommand.Create(() =>
+ {
+ if (ExistingWallet is null)
+ {
+ return;
+ }
+
+ Navigate().Clear();
+ Navigate(NavigationTarget.HomeScreen).To(new LoginViewModel(ExistingWallet), NavigationMode.Clear);
+ });
}
public string WalletName { get; }
public WalletManager WalletManager { get; }
+ public ObservableCollection<WalletViewModelBase> Wallets { get; }
+
+ public WalletViewModelBase? ExistingWallet { get; set; }
+
public HardwareWalletOperations HardwareWalletOperations { get; }
public ICommand OpenBrowserCommand { get; }
+ public ICommand NavigateToExistingWalletLoginCommand { get; }
+
private void RunDetection()
{
IsSearching = true;
+ ExistingWalletFound = false;
Message = "";
HardwareWalletOperations.StartDetection();
}
@@ -69,6 +93,14 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
var device = devices[0];
+ if (WalletManager.WalletExists(device.Fingerprint))
+ {
+ ExistingWallet = Wallets.FirstOrDefault(x => x.Wallet.KeyManager.MasterFingerprint == device.Fingerprint);
+ Message = "The connected hardware wallet is already added to the software, click below to login or click Continue to search again.";
+ ExistingWalletFound = true;
+ return;
+ }
+
if (!device.IsInitialized())
{
if (device.Model == HardwareWalletModels.Coldcard)

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/HardwareWalletOperations.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/HardwareWalletOperations.cs
@@ -107,7 +107,6 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
var detectedHardwareWallets =
(await Client.EnumerateAsync(timeoutCts.Token)
.ConfigureAwait(false))
- .Where(wallet => !WalletManager.WalletExists(wallet.Fingerprint))
.ToArray();
detectionCts.Token.ThrowIfCancellationRequested();

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -73,7 +73,8 @@ namespace WalletWasabi.Fluent.ViewModels
global.LegalDocuments,
global.WalletManager,
global.BitcoinStore,
- global.Network);
+ global.Network,
+ _walletManager.Items);
_settingsPage = new SettingsPageViewModel(global.Config, global.UiConfig);
_privacyMode = new PrivacyModeViewModel(global.UiConfig);

MODIFY
WalletWasabi.Fluent/Views/AddWallet/HardwareWallet/ConnectHardwareWalletView.axaml
WalletWasabi.Fluent/Views/AddWallet/HardwareWallet/ConnectHardwareWalletView.axaml
</Viewbox>
<Panel HorizontalAlignment="Center" VerticalAlignment="Center">
- <TextBlock Text="{Binding Message}" TextWrapping="Wrap" TextAlignment="Center" />
+ <DockPanel>
+ <TextBlock Text="{Binding Message}" TextWrapping="Wrap" TextAlignment="Center" DockPanel.Dock="Top"/>
+ <Button IsVisible="{Binding ExistingWalletFound}" Margin="0 15 0 0" Command="{Binding NavigateToExistingWalletLoginCommand}" Content="Click here to login" Classes="h7 plain activeHyperLink" HorizontalAlignment="Center" VerticalAlignment="Bottom" DockPanel.Dock="Bottom"/>
+ </DockPanel>
<c:ProgressRing IsVisible="{Binding IsSearching}" Margin="15" IsIndeterminate="True" Height="100" Width="100" />
</Panel>
</DockPanel>

existing wallet detection