add ReceiveWalletActionViewModel
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -66,7 +66,7 @@ namespace WalletWasabi.Fluent.ViewModels
global.BitcoinStore.SmartHeaderChain,
global.Synchronizer);
- _walletManagerViewModel = new WalletManagerViewModel(global.WalletManager, global.UiConfig);
+ _walletManagerViewModel = new WalletManagerViewModel(global.WalletManager, global.UiConfig, _global.BitcoinStore);
_addWalletPage = new AddWalletPageViewModel(
_walletManagerViewModel,

MODIFY
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
@@ -13,6 +13,7 @@ using WalletWasabi.Fluent.ViewModels.Wallets.Actions;
using WalletWasabi.Fluent.ViewModels.Wallets.Send;
using WalletWasabi.Gui;
using WalletWasabi.Gui.ViewModels;
+using WalletWasabi.Stores;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels
@@ -29,9 +30,10 @@ namespace WalletWasabi.Fluent.ViewModels
[AutoNotify] private ObservableCollection<WalletViewModelBase> _wallets;
[AutoNotify] private bool _anyWalletStarted;
- public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig)
+ public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, BitcoinStore bitcoinStore)
{
Model = walletManager;
+ BitcoinStore = bitcoinStore;
_walletDictionary = new Dictionary<Wallet, WalletViewModelBase>();
_walletActionsDictionary = new Dictionary<WalletViewModelBase, List<NavBarItemViewModel>>();
_actions = new ObservableCollection<NavBarItemViewModel>();
@@ -100,6 +102,8 @@ namespace WalletWasabi.Fluent.ViewModels
public WalletManager Model { get; }
+ public BitcoinStore BitcoinStore { get; }
+
private void OpenClosedWallet(WalletManager walletManager, UiConfig uiConfig, ClosedWalletViewModel closedWalletViewModel)
{
RemoveWallet(closedWalletViewModel);
@@ -222,7 +226,7 @@ namespace WalletWasabi.Fluent.ViewModels
actions.Add(new SendViewModel(walletViewModel));
}
- actions.Add(new ReceiveWalletActionViewModel(walletViewModel));
+ actions.Add(new ReceiveWalletActionViewModel(walletViewModel, Model, BitcoinStore));
if (!wallet.KeyManager.IsWatchOnly)
{

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Actions/ReceiveWalletActionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Actions/ReceiveWalletActionViewModel.cs
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using System.Windows.Input;
+using ReactiveUI;
+using WalletWasabi.Blockchain.Analysis.Clustering;
+using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Fluent.ViewModels.NavBar;
+using WalletWasabi.Stores;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Actions
{
@@ -11,10 +21,68 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Actions
NavigationTarget = NavigationTarget.DialogScreen)]
public partial class ReceiveWalletActionViewModel : NavBarItemViewModel
{
- public ReceiveWalletActionViewModel(WalletViewModelBase wallet)
+ [AutoNotify] private string _reference;
+ [AutoNotify] private HashSet<string> _suggestions;
+ [AutoNotify] private bool _isExistingAddressesButtonVisible;
+
+ public ReceiveWalletActionViewModel(WalletViewModelBase wallet, WalletManager walletManager, BitcoinStore bitcoinStore)
{
- Title = "Receive";
SelectionMode = NavBarItemSelectionMode.Button;
+ WasabiWallet = wallet.Wallet;
+ _reference = "";
+ _suggestions = GetLabels(walletManager, bitcoinStore);
+
+ var nextCommandCanExecute =
+ this.WhenAnyValue(x => x.Reference)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Select(reference => !string.IsNullOrEmpty(reference));
+
+ NextCommand = ReactiveCommand.Create(
+ () =>
+ {
+ var newKey = WasabiWallet.KeyManager.GetNextReceiveKey(Reference, out bool minGapLimitIncreased);
+
+ if (minGapLimitIncreased)
+ {
+ int minGapLimit = WasabiWallet.KeyManager.MinGapLimit.Value;
+ int prevMinGapLimit = minGapLimit - 1;
+ var minGapLimitMessage = $"Minimum gap limit increased from {prevMinGapLimit} to {minGapLimit}.";
+ // TODO: notification
+ }
+
+ Navigate().To(new ReceiveAddressViewModel(newKey, WasabiWallet.Network, WasabiWallet.KeyManager.MasterFingerprint, WasabiWallet.KeyManager.IsHardwareWallet));
+ },
+ nextCommandCanExecute);
+
+ ShowExistingAddressesCommand = ReactiveCommand.Create(() => Navigate().To(new ReceiveAddressesViewModel(WasabiWallet)));
+ }
+
+ public Wallet WasabiWallet { get; }
+
+ public ICommand ShowExistingAddressesCommand { get; }
+
+ protected override void OnNavigatedTo(bool inStack, CompositeDisposable disposable)
+ {
+ base.OnNavigatedTo(inStack, disposable);
+
+ IsExistingAddressesButtonVisible = WasabiWallet.KeyManager.GetKeys(x => !x.Label.IsEmpty && !x.IsInternal && x.KeyState == KeyState.Clean).Any();
+ Reference = "";
+ }
+
+ private HashSet<string> GetLabels(WalletManager walletManager, BitcoinStore store)
+ {
+ // Don't refresh wallet list as it may be slow.
+ IEnumerable<SmartLabel> labels = walletManager.GetWallets(refreshWalletList: false)
+ .Select(x => x.KeyManager)
+ .SelectMany(x => x.GetLabels());
+
+ var txStore = store.TransactionStore;
+ if (txStore is { })
+ {
+ labels = labels.Concat(txStore.GetLabels());
+ }
+
+ return labels.SelectMany(x => x.Labels).ToHashSet();
}
}
}

add ReceiveWalletActionViewModel