Skip to content

Commit

Permalink
Enable sending queued coins.
Browse files Browse the repository at this point in the history
  • Loading branch information
nopara73 committed Nov 19, 2018
1 parent 4770314 commit 2b07ebb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
Expand Up @@ -106,9 +106,10 @@ public SendTabViewModel(WalletViewModel walletViewModel)
return;
}
var selectedCoins = CoinList.Coins.Where(cvm => cvm.IsSelected).Select(cvm => new TxoRef(cvm.Model.TransactionId, cvm.Model.Index)).ToList();
var selectedCoinViewModels = CoinList.Coins.Where(cvm => cvm.IsSelected);
var selectedCoinReferences = selectedCoinViewModels.Select(cvm => new TxoRef(cvm.Model.TransactionId, cvm.Model.Index)).ToList();
if (!selectedCoins.Any())
if (!selectedCoinReferences.Any())
{
SetWarningMessage("No coins are selected to spend.");
return;
Expand Down Expand Up @@ -139,7 +140,17 @@ public SendTabViewModel(WalletViewModel walletViewModel)
var label = Label.Trim(',', ' ').Trim();
var operation = new WalletService.Operation(script, amount, label);
var result = await Task.Run(async () => await Global.WalletService.BuildTransactionAsync(Password, new[] { operation }, Fee, allowUnconfirmed: true, allowedInputs: selectedCoins));
try
{
await Global.ChaumianClient.DequeueCoinsFromMixAsync(selectedCoinReferences.Select(x => (x.TransactionId, x.Index)).ToArray());
}
catch
{
SetWarningMessage("Spending coins those are being actively mixed is not allowed.");
return;
}
var result = await Task.Run(async () => await Global.WalletService.BuildTransactionAsync(Password, new[] { operation }, Fee, allowUnconfirmed: true, allowedInputs: selectedCoinReferences));
await Task.Run(async () => await Global.WalletService.SendTransactionAsync(result.Transaction));
Expand All @@ -164,7 +175,7 @@ public SendTabViewModel(WalletViewModel walletViewModel)
IsBusy = false;
}
},
this.WhenAny(x => x.IsMax, x => x.Amount, x => x.Address, x => x.IsBusy,
(this).WhenAny(x => x.IsMax, x => x.Amount, x => x.Address, x => x.IsBusy,
(isMax, amount, address, busy) => ((isMax.Value || !string.IsNullOrWhiteSpace(amount.Value)) && !string.IsNullOrWhiteSpace(Address) && !IsBusy)));

MaxCommand = ReactiveCommand.Create(() =>
Expand Down

0 comments on commit 2b07ebb

Please sign in to comment.