Pass WalletService instead of WalletViewModel.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/BuildTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/BuildTabViewModel.cs
@@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Gui.Helpers;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -15,7 +16,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override string DoButtonText => "Build Transaction";
public override string DoingButtonText => "Building Transaction...";
- public BuildTabViewModel(WalletViewModel walletViewModel) : base(walletViewModel, "Build Transaction")
+ public BuildTabViewModel(WalletService walletService) : base(walletService, "Build Transaction")
{
}
@@ -23,7 +24,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
try
{
- var txviewer = new TransactionViewerViewModel(Wallet);
+ var txviewer = new TransactionViewerViewModel();
IoC.Get<IShell>().AddDocument(txviewer);
IoC.Get<IShell>().Select(txviewer);

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -27,8 +27,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public class CoinJoinTabViewModel : WalletActionViewModel
{
- private CompositeDisposable Disposables { get; set; }
-
private long _roundId;
private RoundPhaseState _roundPhaseState;
private DateTimeOffset _roundTimesout;
@@ -50,10 +48,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private int _coinJoinUntilAnonymitySet;
private TargetPrivacy _targetPrivacy;
- public CoinJoinTabViewModel(WalletViewModel walletViewModel)
- : base("CoinJoin", walletViewModel)
+ public CoinJoinTabViewModel(WalletService walletService)
+ : base("CoinJoin")
{
Global = Locator.Current.GetService<Global>();
+ WalletService = walletService;
Password = "";
TimeLeftTillRoundTimeout = TimeSpan.Zero;
@@ -132,6 +131,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Global Global { get; }
+ private WalletService WalletService { get; }
+
+ private CompositeDisposable Disposables { get; set; }
+
public override void OnOpen()
{
base.OnOpen();
@@ -240,7 +243,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
try
{
- PasswordHelper.GetMasterExtKey(KeyManager, Password, out string compatiblityPassword); // If the password is not correct we throw.
+ PasswordHelper.GetMasterExtKey(WalletService.KeyManager, Password, out string compatiblityPassword); // If the password is not correct we throw.
if (compatiblityPassword != null)
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -13,6 +13,7 @@ using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Gui.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Models;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -28,12 +29,15 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Global Global { get; }
+ private WalletService WalletService { get; }
+
public ReactiveCommand<Unit, Unit> SortCommand { get; }
- public HistoryTabViewModel(WalletViewModel walletViewModel)
- : base("History", walletViewModel)
+ public HistoryTabViewModel(WalletService walletService)
+ : base("History")
{
Global = Locator.Current.GetService<Global>();
+ WalletService = walletService;
Transactions = new ObservableCollection<TransactionViewModel>();

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -19,6 +19,7 @@ using WalletWasabi.Logging;
using WalletWasabi.Hwi;
using WalletWasabi.Hwi.Exceptions;
using Splat;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -33,10 +34,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public ReactiveCommand<Unit, Unit> GenerateCommand { get; }
- public ReceiveTabViewModel(WalletViewModel walletViewModel)
- : base("Receive", walletViewModel)
+ public ReceiveTabViewModel(WalletService walletService)
+ : base("Receive")
{
Global = Locator.Current.GetService<Global>();
+ WalletService = walletService;
+
LabelSuggestion = new SuggestLabelViewModel(WalletService);
_addresses = new ObservableCollection<AddressViewModel>();
LabelSuggestion.Label = "";
@@ -55,15 +58,15 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
AvaloniaThreadingExtensions.PostLogException(Dispatcher.UIThread, () =>
{
- var newKey = KeyManager.GetNextReceiveKey(label, out bool minGapLimitIncreased);
+ var newKey = WalletService.KeyManager.GetNextReceiveKey(label, out bool minGapLimitIncreased);
if (minGapLimitIncreased)
{
- int minGapLimit = KeyManager.MinGapLimit.Value;
+ int minGapLimit = WalletService.KeyManager.MinGapLimit.Value;
int prevMinGapLimit = minGapLimit - 1;
NotificationHelpers.Warning($"{nameof(KeyManager.MinGapLimit)} increased from {prevMinGapLimit} to {minGapLimit}.");
}
- var newAddress = new AddressViewModel(newKey, KeyManager);
+ var newAddress = new AddressViewModel(newKey, WalletService.KeyManager);
Addresses.Insert(0, newAddress);
SelectedAddress = newAddress;
LabelSuggestion.Label = "";
@@ -91,6 +94,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
});
}
+ private WalletService WalletService { get; }
+
public SuggestLabelViewModel LabelSuggestion { get; }
public override void OnOpen()
@@ -121,10 +126,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
_addresses?.Clear();
- IEnumerable<HdPubKey> keys = KeyManager.GetKeys(x => !x.Label.IsEmpty && !x.IsInternal && x.KeyState == KeyState.Clean).Reverse();
+ IEnumerable<HdPubKey> keys = WalletService.KeyManager.GetKeys(x => !x.Label.IsEmpty && !x.IsInternal && x.KeyState == KeyState.Clean).Reverse();
foreach (HdPubKey key in keys)
{
- _addresses.Add(new AddressViewModel(key, KeyManager));
+ _addresses.Add(new AddressViewModel(key, WalletService.KeyManager));
}
}
catch (Exception ex)

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -36,6 +36,7 @@ using WalletWasabi.Hwi.Exceptions;
using WalletWasabi.Hwi.Models;
using WalletWasabi.Logging;
using WalletWasabi.Models;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -44,6 +45,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private CompositeDisposable Disposables { get; set; }
protected Global Global { get; }
+ private WalletService WalletService { get; }
private string _buildTransactionButtonText;
private bool _isMax;
@@ -99,10 +101,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
AmountText = "0.0";
}
- protected SendControlViewModel(WalletViewModel walletViewModel, string title)
- : base(title, walletViewModel)
+ protected SendControlViewModel(WalletService walletService, string title)
+ : base(title)
{
Global = Locator.Current.GetService<Global>();
+ WalletService = walletService;
+
LabelSuggestion = new SuggestLabelViewModel(WalletService);
BuildTransactionButtonText = DoButtonText;
@@ -315,11 +319,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
MainWindowViewModel.Instance.StatusBar.TryRemoveStatus(StatusType.DequeuingSelectedCoins);
}
- if (!KeyManager.IsWatchOnly)
+ if (!WalletService.KeyManager.IsWatchOnly)
{
try
{
- PasswordHelper.GetMasterExtKey(KeyManager, Password, out string compatiblityPasswordUsed); // We could use TryPassword but we need the exception.
+ PasswordHelper.GetMasterExtKey(WalletService.KeyManager, Password, out string compatiblityPasswordUsed); // We could use TryPassword but we need the exception.
if (compatiblityPasswordUsed != null)
{
Password = compatiblityPasswordUsed; // Overwrite the password for BuildTransaction function.

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -9,6 +9,7 @@ using WalletWasabi.Gui.Models.StatusBarStatuses;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Hwi;
using WalletWasabi.Hwi.Exceptions;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -17,16 +18,19 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override string DoButtonText => "Send Transaction";
public override string DoingButtonText => "Sending Transaction...";
- public SendTabViewModel(WalletViewModel walletViewModel) : base(walletViewModel, "Send")
+ public SendTabViewModel(WalletService walletService) : base(walletService, "Send")
{
+ WalletService = walletService;
}
+ private WalletService WalletService { get; }
+
protected override async Task DoAfterBuildTransaction(BuildTransactionResult result)
{
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusType.SigningTransaction);
SmartTransaction signedTransaction = result.Transaction;
- if (IsHardwareWallet && !result.Signed) // If hardware but still has a privkey then it's password, then meh.
+ if (WalletService.KeyManager.IsHardwareWallet && !result.Signed) // If hardware but still has a privkey then it's password, then meh.
{
try
{
@@ -38,12 +42,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
PSBT signedPsbt = null;
try
{
- signedPsbt = await client.SignTxAsync(KeyManager.MasterFingerprint.Value, result.Psbt, cts.Token);
+ signedPsbt = await client.SignTxAsync(WalletService.KeyManager.MasterFingerprint.Value, result.Psbt, cts.Token);
}
catch (HwiException)
{
await PinPadViewModel.UnlockAsync();
- signedPsbt = await client.SignTxAsync(KeyManager.MasterFingerprint.Value, result.Psbt, cts.Token);
+ signedPsbt = await client.SignTxAsync(WalletService.KeyManager.MasterFingerprint.Value, result.Psbt, cts.Token);
}
signedTransaction = signedPsbt.ExtractSmartTransaction(result.Transaction);
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
@@ -29,7 +29,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private string _psbtBase64Text;
private byte[] _psbtBytes;
- public TransactionViewerViewModel(WalletViewModel walletViewModel) : base("Transaction", walletViewModel)
+ public TransactionViewerViewModel() : base("Transaction")
{
Global = Locator.Current.GetService<Global>();

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletActionViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletActionViewModel.cs
-using Avalonia.Threading;
-using AvalonStudio.Extensibility;
-using AvalonStudio.Shell;
-using ReactiveUI;
-using System.Reactive;
-using System.Threading.Tasks;
-using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Gui.ViewModels;
-using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public class WalletActionViewModel : WasabiDocumentTabViewModel
{
- public WalletViewModel Wallet { get; }
-
- public WalletService WalletService => Wallet.WalletService;
- public KeyManager KeyManager => WalletService.KeyManager;
- public bool IsWatchOnly => KeyManager.IsWatchOnly;
- public bool IsHardwareWallet => KeyManager.IsHardwareWallet;
-
- public WalletActionViewModel(string title, WalletViewModel walletViewModel)
+ public WalletActionViewModel(string title)
: base(title)
{
- Wallet = walletViewModel;
}
}
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletAdvancedViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletAdvancedViewModel.cs
@@ -4,6 +4,8 @@ using System.Reactive;
using System.Reactive.Linq;
using WalletWasabi.Logging;
using System;
+using System.IO;
+using WalletWasabi.Services;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -21,7 +23,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _isExpanded, value);
}
- public WalletAdvancedViewModel(WalletViewModel walletViewModel) : base(walletViewModel.Name, walletViewModel)
+ public WalletAdvancedViewModel(WalletService walletService) : base(Path.GetFileNameWithoutExtension(walletService.KeyManager.FilePath))
{
Items = new ObservableCollection<WalletActionViewModel>();

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -15,6 +15,7 @@ using WalletWasabi.Gui.Helpers;
using WalletWasabi.Logging;
using System.Reactive.Linq;
using Splat;
+using System.IO;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -31,9 +32,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Global Global { get; }
- public WalletInfoViewModel(WalletViewModel walletViewModel) : base(walletViewModel.Name, walletViewModel)
+ public WalletInfoViewModel(WalletService walletService) : base(Path.GetFileNameWithoutExtension(walletService.KeyManager.FilePath))
{
Global = Locator.Current.GetService<Global>();
+ WalletService = walletService;
ClearSensitiveData(true);
@@ -45,7 +47,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
else
{
- var secret = PasswordHelper.GetMasterExtKey(KeyManager, Password, out string isCompatibilityPasswordUsed);
+ var secret = PasswordHelper.GetMasterExtKey(WalletService.KeyManager, Password, out string isCompatibilityPasswordUsed);
Password = "";
if (isCompatibilityPasswordUsed != null)
@@ -54,9 +56,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
string master = secret.GetWif(Global.Network).ToWif();
- string account = secret.Derive(KeyManager.AccountKeyPath).GetWif(Global.Network).ToWif();
+ string account = secret.Derive(WalletService.KeyManager.AccountKeyPath).GetWif(Global.Network).ToWif();
string masterZ = secret.ToZPrv(Global.Network);
- string accountZ = secret.Derive(KeyManager.AccountKeyPath).ToZPrv(Global.Network);
+ string accountZ = secret.Derive(WalletService.KeyManager.AccountKeyPath).ToZPrv(Global.Network);
SetSensitiveData(master, account, masterZ, accountZ);
}
});
@@ -70,6 +72,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
});
}
+ private WalletService WalletService { get; }
+
private void ClearSensitiveData(bool passwordToo)
{
ExtendedMasterPrivateKey = "";
@@ -86,10 +90,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public CancellationTokenSource Closing { get; private set; }
- public string ExtendedAccountPublicKey => KeyManager.ExtPubKey.ToString(Global.Network);
- public string ExtendedAccountZpub => KeyManager.ExtPubKey.ToZpub(Global.Network);
- public string AccountKeyPath => $"m/{KeyManager.AccountKeyPath}";
- public string MasterKeyFingerprint => KeyManager.MasterFingerprint.ToString();
+ public string ExtendedAccountPublicKey => WalletService.KeyManager.ExtPubKey.ToString(Global.Network);
+ public string ExtendedAccountZpub => WalletService.KeyManager.ExtPubKey.ToZpub(Global.Network);
+ public string AccountKeyPath => $"m/{WalletService.KeyManager.AccountKeyPath}";
+ public string MasterKeyFingerprint => WalletService.KeyManager.MasterFingerprint.ToString();
public ReactiveCommand<Unit, Unit> ToggleSensitiveKeysCommand { get; }
public bool ShowSensitiveKeys

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
@@ -52,23 +52,23 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
// If hardware wallet then we need the Send tab.
if (WalletService?.KeyManager?.IsHardwareWallet is true)
{
- sendTab = new SendTabViewModel(this);
+ sendTab = new SendTabViewModel(WalletService);
Actions.Add(sendTab);
}
// If not hardware wallet, but neither watch only then we also need the send tab.
else if (WalletService?.KeyManager?.IsWatchOnly is false)
{
- sendTab = new SendTabViewModel(this);
+ sendTab = new SendTabViewModel(WalletService);
Actions.Add(sendTab);
}
- var receiveTab = new ReceiveTabViewModel(this);
- var coinjoinTab = new CoinJoinTabViewModel(this);
- var historyTab = new HistoryTabViewModel(this);
+ var receiveTab = new ReceiveTabViewModel(WalletService);
+ var coinjoinTab = new CoinJoinTabViewModel(WalletService);
+ var historyTab = new HistoryTabViewModel(WalletService);
- var advancedAction = new WalletAdvancedViewModel(this);
- var infoTab = new WalletInfoViewModel(this);
- var buildTab = new BuildTabViewModel(this);
+ var advancedAction = new WalletAdvancedViewModel(WalletService);
+ var infoTab = new WalletInfoViewModel(WalletService);
+ var buildTab = new BuildTabViewModel(WalletService);
Actions.Add(receiveTab);
Actions.Add(coinjoinTab);

Pass WalletService instead of WalletViewModel.