Example #1
0
        public ConnectHardwareWalletViewModel(string walletName, Network network, WalletManager walletManager)
        {
            IsBusy = true;

            WalletName = walletName;
            HardwareWalletOperations = new HardwareWalletOperations(walletManager, network);
            HardwareWalletOperations.NoHardwareWalletFound += OnNoHardwareWalletFound;

            BackCommand = ReactiveCommand.Create(() =>
            {
                HardwareWalletOperations.Dispose();
                Navigate().Back();
            });

            CancelCommand = ReactiveCommand.Create(() =>
            {
                HardwareWalletOperations.Dispose();
                Navigate().Clear();
            });

            NextCommand = ReactiveCommand.Create(() =>
            {
                HardwareWalletOperations.StartDetection();
                ContinueButtonEnable = false;
                Message = "";
            });

            _message = "";
        }
Example #2
0
        public ConnectHardwareWalletViewModel(string walletName, Network network, WalletManager walletManager)
        {
            Title      = "Hardware Wallet";
            _message   = "";
            IsBusy     = true;
            WalletName = walletName;
            HardwareWalletOperations = new HardwareWalletOperations(walletManager, network);
            HardwareWalletOperations.NoHardwareWalletFound += OnNoHardwareWalletFound;

            BackCommand = ReactiveCommand.Create(() =>
            {
                HardwareWalletOperations.Dispose();
                Navigate().Back();
            });

            CancelCommand = ReactiveCommand.Create(() =>
            {
                HardwareWalletOperations.Dispose();
                Navigate().Clear();
            });

            NextCommand = ReactiveCommand.Create(() =>
            {
                HardwareWalletOperations.StartDetection();
                ContinueButtonEnable = false;
                Message = "";
            });

            // 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"));
        }
Example #3
0
 private void OnNoHardwareWalletFound(object?sender, EventArgs e)
 {
     IsBusy = false;
     ContinueButtonEnable = true;
     Message = "Connect your wallet to the USB port on your PC / Enter the PIN on the Wallet.";
     Task.Run(() => HardwareWalletOperations.StopDetectionAsync());
     HardwareWalletOperations.NoHardwareWalletFound -= OnNoHardwareWalletFound;
 }
Example #4
0
        public DetectedHardwareWalletViewModel(HardwareWalletOperations hardwareWalletOperations, string walletName)
        {
            Title      = "Hardware Wallet";
            WalletName = walletName;

            Type = hardwareWalletOperations.SelectedDevice !.Model switch
            {
                HardwareWalletModels.Coldcard or HardwareWalletModels.Coldcard_Simulator => WalletType.Coldcard,
                                                                      HardwareWalletModels.Ledger_Nano_S => WalletType.Ledger,
                                                                      HardwareWalletModels.Trezor_1 or HardwareWalletModels.Trezor_1_Simulator or HardwareWalletModels.Trezor_T or HardwareWalletModels.Trezor_T_Simulator => WalletType.Trezor,
                                                                      _ => WalletType.Hardware,
            };

            TypeName = hardwareWalletOperations.SelectedDevice.Model.FriendlyName();

            NextCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                IsBusy = true;

                try
                {
                    var km            = await hardwareWalletOperations.GenerateWalletAsync(WalletName);
                    var walletManager = hardwareWalletOperations.WalletManager;
                    hardwareWalletOperations.Dispose();
                    km.SetIcon(Type);

                    Navigate().To(new AddedWalletPageViewModel(walletManager, km));
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    await ShowErrorAsync(ex.ToUserFriendlyString(), "Error occured during adding your wallet.");
                    Navigate().Back();
                }

                IsBusy = false;
            });

            NoCommand = ReactiveCommand.Create(() => Navigate().Back());
        }
Example #5
0
        public DetectedHardwareWalletViewModel(HardwareWalletOperations hardwareWalletOperations, string walletName)
        {
            WalletName = walletName;

            switch (hardwareWalletOperations.SelectedDevice !.Model)
            {