simplify TransactionHelpers.BuildTransaction input params
MODIFY
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
@@ -4,6 +4,7 @@ using NBitcoin;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Blockchain.TransactionOutputs;
+using WalletWasabi.Fluent.ViewModels.Wallets.Send;
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.PayJoin;
@@ -29,5 +30,19 @@ namespace WalletWasabi.Fluent.Helpers
return txRes;
}
+
+ public static BuildTransactionResult BuildTransaction(Wallet wallet, TransactionInfo transactionInfo, bool subtractFee = false, bool isPayJoin = false)
+ {
+ return BuildTransaction(
+ wallet,
+ transactionInfo.Address,
+ transactionInfo.Amount,
+ transactionInfo.Labels,
+ transactionInfo.FeeRate,
+ transactionInfo.Coins,
+ subtractFee,
+ isPayJoin ? transactionInfo.PayJoinClient : null);
+
+ }
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacyControlViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacyControlViewModel.cs
@@ -69,17 +69,17 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
private async Task OnNext(Wallet wallet, TransactionInfo transactionInfo, TransactionBroadcaster broadcaster, IObservableList<PocketViewModel> selectedList)
{
- var coins = selectedList.Items.SelectMany(x => x.Coins).ToArray();
+ transactionInfo.Coins = selectedList.Items.SelectMany(x => x.Coins).ToArray();
try
{
if (transactionInfo.PayJoinClient is { })
{
- await BuildPayJoinTransactionAsync(wallet, transactionInfo, coins, broadcaster);
+ await BuildPayJoinTransactionAsync(wallet, transactionInfo, broadcaster);
}
else
{
- await BuildNormalTransactionAsync(wallet, transactionInfo, coins, broadcaster);
+ await BuildNormalTransactionAsync(wallet, transactionInfo, broadcaster);
}
}
catch (Exception ex)
@@ -90,16 +90,16 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- private async Task BuildNormalTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, SmartCoin[] coins, TransactionBroadcaster broadcaster)
+ private async Task BuildNormalTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, TransactionBroadcaster broadcaster)
{
try
{
- var transactionResult = await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, transactionInfo.Address, transactionInfo.Amount, transactionInfo.Labels, transactionInfo.FeeRate, coins, subtractFee: false));
+ var transactionResult = await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, transactionInfo));
Navigate().To(new TransactionPreviewViewModel(wallet, transactionInfo, broadcaster, transactionResult));
}
catch (InsufficientBalanceException)
{
- var transactionResult = await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, transactionInfo.Address, transactionInfo.Amount, transactionInfo.Labels, transactionInfo.FeeRate, coins, subtractFee: true));
+ var transactionResult = await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, transactionInfo, subtractFee: true));
var dialog = new InsufficientBalanceDialogViewModel(BalanceType.Pocket, transactionResult, wallet.Synchronizer.UsdExchangeRate);
var result = await NavigateDialog(dialog, NavigationTarget.DialogScreen);
@@ -114,11 +114,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- private async Task BuildPayJoinTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, SmartCoin[] coins, TransactionBroadcaster broadcaster)
+ private async Task BuildPayJoinTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, TransactionBroadcaster broadcaster)
{
try
{
- var transactionResult = await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, transactionInfo.Address, transactionInfo.Amount, transactionInfo.Labels, transactionInfo.FeeRate, coins, subtractFee: false));
+ var transactionResult = await Task.Run(() => TransactionHelpers.BuildTransaction(_wallet, transactionInfo));
Navigate().To(new TransactionPreviewViewModel(wallet, transactionInfo, broadcaster, transactionResult));
}
catch (InsufficientBalanceException)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -165,6 +165,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
var targetAnonymitySet = wallet.ServiceConfiguration.GetMixUntilAnonymitySetValue();
var mixedCoins = wallet.Coins.Where(x => x.HdPubKey.AnonymitySet >= targetAnonymitySet).ToList();
var totalMixedCoinsAmount = Money.FromUnit(mixedCoins.Sum(coin => coin.Amount), MoneyUnit.Satoshi);
+ transactionInfo.Coins = mixedCoins;
if (transactionInfo.Amount > totalMixedCoinsAmount)
{
@@ -176,11 +177,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
if (IsPayJoin)
{
- await BuildPayJoinTransactionAsync(wallet, transactionInfo, mixedCoins, broadcaster);
+ await BuildPayJoinTransactionAsync(wallet, transactionInfo, broadcaster);
}
else
{
- await BuildNormalTransactionAsync(wallet, transactionInfo, mixedCoins, broadcaster, totalMixedCoinsAmount);
+ await BuildNormalTransactionAsync(wallet, transactionInfo, broadcaster, totalMixedCoinsAmount);
}
}
catch (Exception ex)
@@ -190,16 +191,16 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- private async Task BuildNormalTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, List<SmartCoin> coins, TransactionBroadcaster broadcaster, Money totalMixedCoinsAmount)
+ private async Task BuildNormalTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, TransactionBroadcaster broadcaster, Money totalMixedCoinsAmount)
{
try
{
- var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo.Address, transactionInfo.Amount, transactionInfo.Labels, transactionInfo.FeeRate, coins, subtractFee: false));
+ var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo));
Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, broadcaster, txRes));
}
catch (InsufficientBalanceException)
{
- var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo.Address, totalMixedCoinsAmount, transactionInfo.Labels, transactionInfo.FeeRate, coins, subtractFee: true));
+ var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo.Address, totalMixedCoinsAmount, transactionInfo.Labels, transactionInfo.FeeRate, transactionInfo.Coins, subtractFee: true));
var dialog = new InsufficientBalanceDialogViewModel(BalanceType.Private, txRes, wallet.Synchronizer.UsdExchangeRate);
var result = await NavigateDialog(dialog, NavigationTarget.DialogScreen);
@@ -214,11 +215,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- private async Task BuildPayJoinTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, List<SmartCoin> coins, TransactionBroadcaster broadcaster)
+ private async Task BuildPayJoinTransactionAsync(Wallet wallet, TransactionInfo transactionInfo, TransactionBroadcaster broadcaster)
{
try
{
- var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo.Address, transactionInfo.Amount, transactionInfo.Labels, transactionInfo.FeeRate, coins, subtractFee: false));
+ var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo));
Navigate().To(new TransactionPreviewViewModel(wallet, transactionInfo, broadcaster, txRes));
}
catch (InsufficientBalanceException)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -91,14 +91,14 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- private SmartTransaction GetFinalTransaction(SmartTransaction transaction, TransactionInfo info)
+ private SmartTransaction GetFinalTransaction(SmartTransaction transaction, TransactionInfo transactionInfo)
{
- if (info.PayJoinClient is null)
+ if (transactionInfo.PayJoinClient is null)
{
return transaction;
}
- var payJoinTransaction = TransactionHelpers.BuildTransaction(_wallet, info.Address, info.Amount, info.Labels, info.FeeRate, info.Coins, false, info.PayJoinClient);
+ var payJoinTransaction = TransactionHelpers.BuildTransaction(_wallet, transactionInfo, subtractFee: false, isPayJoin: true);
return payJoinTransaction.Transaction;
}

simplify TransactionHelpers.BuildTransaction input params