refactor use of TransactionInfo.Address
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/AdvancedSendOptionsViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/AdvancedSendOptionsViewModel.cs
@@ -13,11 +13,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
[NavigationMetaData(Title = "Advanced")]
public partial class AdvancedSendOptionsViewModel : DialogViewModelBase<Unit>
{
- private readonly TransactionInfo _transactionInfo;
+ private readonly PartialTransactionInfo _transactionInfo;
[AutoNotify] private string _customFee;
- public AdvancedSendOptionsViewModel(TransactionInfo transactionInfo)
+ public AdvancedSendOptionsViewModel(PartialTransactionInfo transactionInfo)
{
_transactionInfo = transactionInfo;

ADD
WalletWasabi.Fluent/ViewModels/Wallets/Send/PartialTransactionInfo.cs
+using System.Collections.Generic;
+using System.Linq;
+using NBitcoin;
+using ReactiveUI;
+using WalletWasabi.Blockchain.Analysis.Clustering;
+using WalletWasabi.Blockchain.TransactionOutputs;
+using WalletWasabi.WebClients.PayJoin;
+
+namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
+
+public partial class PartialTransactionInfo
+{
+ private readonly int _privateCoinThreshold;
+
+ [AutoNotify] private Money _amount = Money.Zero;
+
+ public PartialTransactionInfo()
+ {
+ _privateCoinThreshold = Services.Config.MinAnonScoreTarget;
+
+ this.WhenAnyValue(x => x.Amount)
+ .Subscribe(_ => OnAmountChanged());
+ }
+
+ public TransactionInfo ToFullTransaction(BitcoinAddress address)
+ {
+ return new TransactionInfo(address)
+ {
+ Amount = Amount,
+ UserLabels = UserLabels,
+ FeeRate = FeeRate,
+ MaximumPossibleFeeRate = MaximumPossibleFeeRate,
+ ConfirmationTimeSpan = ConfirmationTimeSpan,
+ Coins = Coins,
+ ChangelessCoins = ChangelessCoins,
+ PayJoinClient = PayJoinClient,
+ IsCustomFeeUsed = IsCustomFeeUsed,
+ SubtractFee = SubtractFee
+ };
+ }
+
+ public SmartLabel UserLabels { get; set; } = SmartLabel.Empty;
+
+ public FeeRate FeeRate { get; set; } = FeeRate.Zero;
+
+ public FeeRate? MaximumPossibleFeeRate { get; set; }
+
+ public TimeSpan ConfirmationTimeSpan { get; set; }
+
+ public IEnumerable<SmartCoin> Coins { get; set; } = Enumerable.Empty<SmartCoin>();
+
+ public IEnumerable<SmartCoin> ChangelessCoins { get; set; } = Enumerable.Empty<SmartCoin>();
+
+ public IPayjoinClient? PayJoinClient { get; set; }
+
+ public bool IsPayJoin => PayJoinClient is { };
+
+ public bool IsOptimized => ChangelessCoins.Any();
+
+ public bool IsPrivate => Coins.All(x => x.HdPubKey.AnonymitySet >= _privateCoinThreshold);
+
+ public bool IsCustomFeeUsed { get; set; }
+
+ public bool SubtractFee { get; set; }
+
+ private void OnAmountChanged()
+ {
+ SubtractFee = default;
+ ChangelessCoins = Enumerable.Empty<SmartCoin>();
+ MaximumPossibleFeeRate = null;
+
+ if (!IsCustomFeeUsed)
+ {
+ FeeRate = FeeRate.Zero;
+ }
+
+ if (Coins.Sum(x => x.Amount) < Amount) // Reset coins if the selected cluster is not enough for the new amount
+ {
+ Coins = Enumerable.Empty<SmartCoin>();
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
-using System;
-using System.Linq;
-using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
@@ -37,7 +34,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
public partial class SendViewModel : RoutableViewModel
{
private readonly Wallet _wallet;
- private readonly TransactionInfo _transactionInfo;
+ private readonly PartialTransactionInfo _transactionInfo;
[AutoNotify] private string _to;
[AutoNotify] private decimal _amountBtc;
[AutoNotify] private decimal _exchangeRate;
@@ -45,12 +42,13 @@ public partial class SendViewModel : RoutableViewModel
[AutoNotify] private bool _isPayJoin;
[AutoNotify] private string? _payJoinEndPoint;
private bool _parsingUrl;
+ private BitcoinAddress? _currentAddress;
public SendViewModel(Wallet wallet)
{
_to = "";
_wallet = wallet;
- _transactionInfo = new TransactionInfo();
+ _transactionInfo = new PartialTransactionInfo();
IsQrButtonVisible = WebcamQrReader.IsOsPlatformSupported;
@@ -108,10 +106,14 @@ public partial class SendViewModel : RoutableViewModel
});
NextCommand = ReactiveCommand.Create(() =>
+ {
+ if (_currentAddress is { })
{
_transactionInfo.Amount = new Money(AmountBtc, MoneyUnit.BTC);
- Navigate().To(new TransactionPreviewViewModel(wallet, _transactionInfo));
+ Navigate().To(new TransactionPreviewViewModel(wallet,
+ _transactionInfo.ToFullTransaction(_currentAddress)));
+ }
}, nextCommandCanExecute);
}
@@ -252,7 +254,7 @@ public partial class SendViewModel : RoutableViewModel
if (url.Address is { })
{
- _transactionInfo.Address = url.Address;
+ _currentAddress = url.Address;
To = url.Address.ToString();
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionInfo.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionInfo.cs
-using System.Collections.Generic;
-using System.Linq;
using NBitcoin;
-using ReactiveUI;
-using WalletWasabi.Blockchain.Analysis.Clustering;
-using WalletWasabi.Blockchain.TransactionOutputs;
-using WalletWasabi.WebClients.PayJoin;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
-public partial class TransactionInfo
+public class TransactionInfo : PartialTransactionInfo
{
- private readonly int _privateCoinThreshold;
-
- [AutoNotify] private Money _amount = Money.Zero;
-
- public TransactionInfo()
- {
- _privateCoinThreshold = Services.Config.MinAnonScoreTarget;
-
- this.WhenAnyValue(x => x.Amount)
- .Subscribe(_ => OnAmountChanged());
- }
-
- public SmartLabel UserLabels { get; set; } = SmartLabel.Empty;
-
- public BitcoinAddress? Address { get; set; }
-
- public FeeRate FeeRate { get; set; } = FeeRate.Zero;
-
- public FeeRate? MaximumPossibleFeeRate { get; set; }
-
- public TimeSpan ConfirmationTimeSpan { get; set; }
-
- public IEnumerable<SmartCoin> Coins { get; set; } = Enumerable.Empty<SmartCoin>();
-
- public IEnumerable<SmartCoin> ChangelessCoins { get; set; } = Enumerable.Empty<SmartCoin>();
-
- public IPayjoinClient? PayJoinClient { get; set; }
-
- public bool IsPayJoin => PayJoinClient is { };
-
- public bool IsOptimized => ChangelessCoins.Any();
-
- public bool IsPrivate => Coins.All(x => x.HdPubKey.AnonymitySet >= _privateCoinThreshold);
-
- public bool IsCustomFeeUsed { get; set; }
-
- public bool SubtractFee { get; set; }
-
- private void OnAmountChanged()
- {
- SubtractFee = default;
- ChangelessCoins = Enumerable.Empty<SmartCoin>();
- MaximumPossibleFeeRate = null;
-
- if (!IsCustomFeeUsed)
+ public TransactionInfo(BitcoinAddress address)
{
- FeeRate = FeeRate.Zero;
+ Address = address;
}
- if (Coins.Sum(x => x.Amount) < Amount) // Reset coins if the selected cluster is not enough for the new amount
- {
- Coins = Enumerable.Empty<SmartCoin>();
- }
- }
+ public BitcoinAddress Address { get; }
}
\ No newline at end of file

refactor use of TransactionInfo.Address