Add enough selected (without build tx preview)
MODIFY
WalletWasabi.Fluent/ViewModels/CoinControl/SelectCoinsDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/CoinControl/SelectCoinsDialogViewModel.cs
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
+using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.Controls.Models.TreeDataGrid;
using Avalonia.Controls.Templates;
+using DynamicData;
using NBitcoin;
using ReactiveUI;
using WalletWasabi.Blockchain.TransactionOutputs;
@@ -27,7 +29,7 @@ namespace WalletWasabi.Fluent.ViewModels.CoinControl;
NavigationTarget = NavigationTarget.DialogScreen)]
public partial class SelectCoinsDialogViewModel : DialogViewModelBase<IEnumerable<SmartCoin>>
{
- public SelectCoinsDialogViewModel(WalletViewModel walletViewModel, IEnumerable<SmartCoin> selectedCoins)
+ public SelectCoinsDialogViewModel(WalletViewModel walletViewModel, IEnumerable<SmartCoin> selectedCoins, Money desiredAmount)
{
var pockets = walletViewModel.Wallet.GetPockets();
var pocketItems = CreatePocketItems(pockets);
@@ -47,14 +49,29 @@ public partial class SelectCoinsDialogViewModel : DialogViewModelBase<IEnumerabl
}
};
+ EnoughSelected = SelectedCoins(pocketItems)
+ .Select(coinItems => new Money(coinItems.Sum(n => n.Amount)))
+ .Select(sum => sum >= desiredAmount);
+
Source.SortBy(pocketColumn, ListSortDirection.Descending);
Source.RowSelection!.SingleSelect = true;
SetupCancel(false, true, false);
EnableBack = true;
- NextCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Normal, GetSelectedCoinItems(pocketItems)));
+ NextCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Normal, GetSelectedCoinItems(pocketItems)), EnoughSelected);
+ }
+
+ private static IObservable<IEnumerable<CoinCoinControlItemViewModel>> SelectedCoins(IReadOnlyCollection<PocketCoinControlItemViewModel> pocketItems)
+ {
+ return GetAllCoinItems(pocketItems)
+ .AsObservableChangeSet()
+ .AutoRefresh(x => x.IsSelected)
+ .ToCollection()
+ .Select(x => x.Where(m => m.IsSelected == true));
}
+ public IObservable<bool> EnoughSelected { get; }
+
public HierarchicalTreeDataGridSource<CoinControlItemViewModelBase> Source { get; }
private static IEnumerable<CoinCoinControlItemViewModel> GetAllCoinItems(IEnumerable<PocketCoinControlItemViewModel> pockets)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -234,7 +234,7 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
var selectedCoins = (Transaction?.SpentCoins ?? new List<SmartCoin>()).ToList();
var selectCoinsDialog =
- await NavigateDialogAsync(new SelectCoinsDialogViewModel(_walletViewModel, selectedCoins));
+ await NavigateDialogAsync(new SelectCoinsDialogViewModel(_walletViewModel, selectedCoins, _info.Amount));
if (selectCoinsDialog.Kind == DialogResultKind.Normal && selectCoinsDialog.Result is { })
{

Add enough selected (without build tx preview)