password auth dialog
DELETE
WalletWasabi.Fluent/ViewModels/Dialogs/EnterPasswordDialogViewModel.cs
-using System.Reactive.Linq;
-using ReactiveUI;
-using WalletWasabi.Fluent.Validation;
-using WalletWasabi.Models;
-using WalletWasabi.Userfacing;
-
-namespace WalletWasabi.Fluent.ViewModels.Dialogs
-{
- [NavigationMetaData(Title = "Enter your password")]
- public partial class EnterPasswordDialogViewModel : DialogViewModelBase<string?>
- {
- [AutoNotify] private string? _password;
-
- public EnterPasswordDialogViewModel(string caption, bool enableEmpty = true)
- {
- Caption = caption;
-
- // This means pressing continue will make the password empty string.
- // pressing cancel will return null.
- _password = "";
-
- var backCommandCanExecute = this.WhenAnyValue(x => x.IsDialogOpen).ObserveOn(RxApp.MainThreadScheduler);
-
- var nextCommandCanExecute = this.WhenAnyValue(
- x => x.IsDialogOpen,
- x => x.Password,
- delegate
- {
- // This will fire validations before return canExecute value.
- this.RaisePropertyChanged(nameof(Password));
-
- return IsDialogOpen &&
- ((enableEmpty && string.IsNullOrEmpty(Password)) ||
- (!string.IsNullOrEmpty(Password) && !Validations.Any));
- })
- .ObserveOn(RxApp.MainThreadScheduler);
-
- var cancelCommandCanExecute = this.WhenAnyValue(x => x.IsDialogOpen).ObserveOn(RxApp.MainThreadScheduler);
-
- BackCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Back), backCommandCanExecute);
- NextCommand = ReactiveCommand.Create(() => Close(result: Password), nextCommandCanExecute);
- CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel), cancelCommandCanExecute);
- }
-
- public string Caption { get; }
-
- protected override void OnDialogClosed()
- {
- Password = "";
- }
- }
-}
\ No newline at end of file

ADD
WalletWasabi.Fluent/ViewModels/Dialogs/PasswordAuthDialogViewModel.cs
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using ReactiveUI;
+using WalletWasabi.Fluent.Validation;
+using WalletWasabi.Models;
+using WalletWasabi.Userfacing;
+using WalletWasabi.Wallets;
+
+namespace WalletWasabi.Fluent.ViewModels.Dialogs
+{
+ [NavigationMetaData(Title = "Enter your password")]
+ public partial class PasswordAuthDialogViewModel : DialogViewModelBase<bool>
+ {
+ [AutoNotify] private string _password;
+
+ public PasswordAuthDialogViewModel(Wallet wallet)
+ {
+ _password = "";
+
+ var canExecute = this.WhenAnyValue(x => x.IsDialogOpen).ObserveOn(RxApp.MainThreadScheduler);
+
+ BackCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Back), canExecute);
+ CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel), canExecute);
+ NextCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ var passwordValid = await Task.Run(() => PasswordHelper.TryPassword(wallet.KeyManager, Password, out _));
+
+ if (!passwordValid)
+ {
+ await ShowErrorAsync("Password", "Password was incorrect.", "");
+ }
+
+ Close(DialogResultKind.Normal, passwordValid);
+ }
+ ,canExecute);
+
+ EnableAutoBusyOn(NextCommand);
+ }
+
+ protected override void OnDialogClosed()
+ {
+ Password = "";
+ }
+ }
+}

RENAME
WalletWasabi.Fluent/Views/Dialogs/EnterPasswordDialogView.axaml.cs
WalletWasabi.Fluent/Views/Dialogs/PasswordAuthDialogView.axaml.cs
@@ -3,9 +3,9 @@ using Avalonia.Markup.Xaml;
namespace WalletWasabi.Fluent.Views.Dialogs
{
- public class EnterPasswordDialogView : UserControl
+ public class PasswordAuthDialogView : UserControl
{
- public EnterPasswordDialogView()
+ public PasswordAuthDialogView()
{
InitializeComponent();
}

password auth dialog