add additional properties to TransactionInfo.cs
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionInfo.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionInfo.cs
@@ -10,14 +10,12 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
public partial class TransactionInfo
{
- private readonly int _privateCoinThreshold;
-
[AutoNotify] private FeeRate _feeRate = FeeRate.Zero;
[AutoNotify] private IEnumerable<SmartCoin> _coins = Enumerable.Empty<SmartCoin>();
public TransactionInfo(int minAnonScoreTarget)
{
- _privateCoinThreshold = minAnonScoreTarget;
+ PrivateCoinThreshold = minAnonScoreTarget;
this.WhenAnyValue(x => x.FeeRate)
.Subscribe(_ => OnFeeChanged());
@@ -26,6 +24,14 @@ public partial class TransactionInfo
.Subscribe(_ => OnCoinsChanged());
}
+ public int PrivateCoinThreshold { get; }
+
+ /// <summary>
+ /// In the case when InsufficientBalanceException happens, this amount should be
+ /// taken into account when selecting pockets.
+ /// </summary>
+ public Money MinimumRequiredAmount { get; set; } = Money.Zero;
+
public Money Amount { get; set; } = Money.Zero;
public SmartLabel UserLabels { get; set; } = SmartLabel.Empty;
@@ -42,21 +48,25 @@ public partial class TransactionInfo
public bool IsOptimized => ChangelessCoins.Any();
- public bool IsPrivate => Coins.All(x => x.HdPubKey.AnonymitySet >= _privateCoinThreshold);
+ public bool IsPrivate => Coins.All(x => x.HdPubKey.AnonymitySet >= PrivateCoinThreshold);
public bool IsCustomFeeUsed { get; set; }
public bool SubtractFee { get; set; }
+ public bool IsOtherPocketSelectionPossible { get; set; }
+
public void Reset()
{
Amount = Money.Zero;
+ MinimumRequiredAmount = Money.Zero;
UserLabels = SmartLabel.Empty;
MaximumPossibleFeeRate = null;
ConfirmationTimeSpan = TimeSpan.Zero;
Coins = Enumerable.Empty<SmartCoin>();
ChangelessCoins = Enumerable.Empty<SmartCoin>();
SubtractFee = default;
+ IsOtherPocketSelectionPossible = default;
if (!IsCustomFeeUsed)
{
@@ -67,6 +77,7 @@ public partial class TransactionInfo
private void OnFeeChanged()
{
ChangelessCoins = Enumerable.Empty<SmartCoin>();
+ MinimumRequiredAmount = Money.Zero;
}
private void OnCoinsChanged()
@@ -76,9 +87,10 @@ public partial class TransactionInfo
public TransactionInfo Clone()
{
- return new TransactionInfo(_privateCoinThreshold)
+ return new TransactionInfo(PrivateCoinThreshold)
{
Amount = Amount,
+ MinimumRequiredAmount = MinimumRequiredAmount,
ChangelessCoins = ChangelessCoins,
Coins = Coins,
ConfirmationTimeSpan = ConfirmationTimeSpan,
@@ -87,7 +99,8 @@ public partial class TransactionInfo
MaximumPossibleFeeRate = MaximumPossibleFeeRate,
PayJoinClient = PayJoinClient,
SubtractFee = SubtractFee,
- UserLabels = UserLabels
+ UserLabels = UserLabels,
+ IsOtherPocketSelectionPossible = IsOtherPocketSelectionPossible
};
}
}

add additional properties to TransactionInfo.cs