Pass around WalletViewModelBase instead of wallet.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/BuildTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/BuildTabViewModel.cs
@@ -16,7 +16,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override string DoButtonText => "Build Transaction";
public override string DoingButtonText => "Building Transaction...";
- public BuildTabViewModel(Wallet wallet) : base(wallet, "Build Transaction")
+ public BuildTabViewModel(WalletViewModel walletViewModel) : base(walletViewModel, "Build Transaction")
{
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -25,7 +25,7 @@ using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
- public class CoinJoinTabViewModel : WasabiDocumentTabViewModel
+ public class CoinJoinTabViewModel : WasabiWalletDocumentTabViewModel
{
private long _roundId;
private RoundPhaseState _roundPhaseState;
@@ -48,11 +48,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private int _coinJoinUntilAnonymitySet;
private TargetPrivacy _targetPrivacy;
- public CoinJoinTabViewModel(Wallet wallet)
- : base("CoinJoin")
+ public CoinJoinTabViewModel(WalletViewModel walletViewModel)
+ : base("CoinJoin", walletViewModel)
{
Global = Locator.Current.GetService<Global>();
- Wallet = wallet;
Password = "";
TimeLeftTillRoundTimeout = TimeSpan.Zero;
@@ -131,8 +130,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Global Global { get; }
- private Wallet Wallet { get; }
-
[ValidateMethod(nameof(ValidatePassword))]
public string Password
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -16,7 +16,7 @@ using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
- public class HistoryTabViewModel : WasabiDocumentTabViewModel
+ public class HistoryTabViewModel : WasabiWalletDocumentTabViewModel
{
private ObservableCollection<TransactionViewModel> _transactions;
private TransactionViewModel _selectedTransaction;
@@ -24,11 +24,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private SortOrder _amountSortDirection;
private SortOrder _transactionSortDirection;
- public HistoryTabViewModel(Wallet wallet)
- : base("History")
+ public HistoryTabViewModel(WalletViewModel walletViewModel)
+ : base("History", walletViewModel)
{
Global = Locator.Current.GetService<Global>();
- Wallet = wallet;
Transactions = new ObservableCollection<TransactionViewModel>();
@@ -48,8 +47,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Global Global { get; }
- private Wallet Wallet { get; }
-
public ReactiveCommand<Unit, Unit> SortCommand { get; }
public override void OnOpen(CompositeDisposable disposables)

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -24,16 +24,15 @@ using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
- public class ReceiveTabViewModel : WasabiDocumentTabViewModel
+ public class ReceiveTabViewModel : WasabiWalletDocumentTabViewModel
{
private ObservableCollection<AddressViewModel> _addresses;
private AddressViewModel _selectedAddress;
- public ReceiveTabViewModel(Wallet wallet)
- : base("Receive")
+ public ReceiveTabViewModel(WalletViewModelBase walletViewModel)
+ : base("Receive", walletViewModel)
{
Global = Locator.Current.GetService<Global>();
- Wallet = wallet;
LabelSuggestion = new SuggestLabelViewModel();
_addresses = new ObservableCollection<AddressViewModel>();
@@ -93,8 +92,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public ReactiveCommand<Unit, Unit> GenerateCommand { get; }
- private Wallet Wallet { get; }
-
public SuggestLabelViewModel LabelSuggestion { get; }
public bool IsHardwareWallet => Wallet.KeyManager.IsHardwareWallet;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -41,10 +41,9 @@ using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
- public abstract class SendControlViewModel : WasabiDocumentTabViewModel
+ public abstract class SendControlViewModel : WasabiWalletDocumentTabViewModel
{
protected Global Global { get; }
- private Wallet Wallet { get; }
private string _buildTransactionButtonText;
private bool _isMax;
@@ -103,11 +102,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
AmountText = "0.0";
}
- protected SendControlViewModel(Wallet wallet, string title)
- : base(title)
+ protected SendControlViewModel(WalletViewModelBase walletViewModel, string title)
+ : base(title, walletViewModel)
{
Global = Locator.Current.GetService<Global>();
- Wallet = wallet;
LabelSuggestion = new SuggestLabelViewModel();
BuildTransactionButtonText = DoButtonText;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -18,13 +18,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override string DoButtonText => "Send Transaction";
public override string DoingButtonText => "Sending Transaction...";
- public SendTabViewModel(Wallet wallet) : base(wallet, "Send")
+ public SendTabViewModel(WalletViewModel walletViewModel) : base(walletViewModel, "Send")
{
- Wallet = wallet;
}
- private Wallet Wallet { get; }
-
protected override async Task DoAfterBuildTransaction(BuildTransactionResult result)
{
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusType.SigningTransaction);

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -18,7 +18,7 @@ using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
- public class WalletInfoViewModel : WasabiDocumentTabViewModel
+ public class WalletInfoViewModel : WasabiWalletDocumentTabViewModel
{
private bool _showSensitiveKeys;
private string _password;
@@ -27,10 +27,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private string _extendedAccountPrivateKey;
private string _extendedAccountZprv;
- public WalletInfoViewModel(Wallet wallet) : base(wallet.WalletName)
+ public WalletInfoViewModel(WalletViewModelBase walletViewModel) : base(walletViewModel.WalletName, walletViewModel)
{
Global = Locator.Current.GetService<Global>();
- Wallet = wallet;
ClearSensitiveData(true);
@@ -69,8 +68,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Global Global { get; }
- private Wallet Wallet { get; }
-
public CancellationTokenSource Closing { get; private set; }
public string ExtendedAccountPublicKey => Wallet.KeyManager.ExtPubKey.ToString(Global.Network);

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
@@ -52,17 +52,17 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
// If hardware wallet or not watch only wallet then we need the Send tab.
if (Wallet.KeyManager.IsHardwareWallet || !Wallet.KeyManager.IsWatchOnly)
{
- SendTab = new SendTabViewModel(Wallet);
+ SendTab = new SendTabViewModel(this);
Actions.Add(SendTab);
}
- ReceiveTab = new ReceiveTabViewModel(Wallet);
- CoinjoinTab = new CoinJoinTabViewModel(Wallet);
- HistoryTab = new HistoryTabViewModel(Wallet);
+ ReceiveTab = new ReceiveTabViewModel(this);
+ CoinjoinTab = new CoinJoinTabViewModel(this);
+ HistoryTab = new HistoryTabViewModel(this);
var advancedAction = new WalletAdvancedViewModel();
- InfoTab = new WalletInfoViewModel(Wallet);
- BuildTab = new BuildTabViewModel(Wallet);
+ InfoTab = new WalletInfoViewModel(this);
+ BuildTab = new BuildTabViewModel(this);
Actions.Add(ReceiveTab);
Actions.Add(CoinjoinTab);

ADD
WalletWasabi.Gui/ViewModels/WasabiWalletDocumentTabViewModel.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+using WalletWasabi.Gui.Controls.WalletExplorer;
+using WalletWasabi.Wallets;
+
+namespace WalletWasabi.Gui.ViewModels
+{
+ public abstract class WasabiWalletDocumentTabViewModel : WasabiDocumentTabViewModel
+ {
+ protected WasabiWalletDocumentTabViewModel(string title, WalletViewModelBase walletViewModel)
+ : base(title)
+ {
+ WalletViewModel = walletViewModel;
+ }
+
+ public WalletViewModelBase WalletViewModel { get; }
+ public Wallet Wallet => WalletViewModel.Wallet;
+ }
+}

Pass around WalletViewModelBase instead of wallet.