Fix RegTest Fee estimation simulation
MODIFY
WalletWasabi.Gui/Behaviors/FocusBehavior.cs
WalletWasabi.Gui/Behaviors/FocusBehavior.cs
@@ -6,12 +6,11 @@ using System.Reactive.Disposables;
namespace WalletWasabi.Gui.Behaviors
{
- class FocusBehavior : Behavior<Control>
+ internal class FocusBehavior : Behavior<Control>
{
private CompositeDisposable _disposables = new CompositeDisposable();
- private Control _attachedControl;
- static readonly AvaloniaProperty<bool> IsFocusedProperty =
+ private static readonly AvaloniaProperty<bool> IsFocusedProperty =
AvaloniaProperty.Register<FocusBehavior, bool>(nameof(IsFocused), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
public bool IsFocused

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -790,7 +790,7 @@ namespace WalletWasabi.Tests
#region SubtractFeeFromAmount
receive = wallet.GetReceiveKey("SubtractFeeFromAmount").GetP2wpkhScript();
- amountToSend = wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Sum(x => x.Amount) / 2;
+ amountToSend = wallet.Coins.Where(x => !x.SpentOrCoinJoinInProcess).Sum(x => x.Amount) / 3;
res = await wallet.BuildTransactionAsync(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, 1008, allowUnconfirmed: true, subtractFeeFromAmountIndex: 0);
Assert.Equal(2, res.InnerWalletOutputs.Count());
@@ -1067,7 +1067,7 @@ namespace WalletWasabi.Tests
// covers:
// customchange
// feePc > 1
- res = await wallet.BuildTransactionAsync(password, new[] { new WalletService.Operation(new Key().ScriptPubKey, new Money(100, MoneyUnit.MilliBTC), "outgoing") }, 1008, customChange: new Key().ScriptPubKey);
+ res = await wallet.BuildTransactionAsync(password, new[] { new WalletService.Operation(new Key().ScriptPubKey, Money.Coins(0.0001m), "outgoing") }, 2, customChange: new Key().ScriptPubKey);
Assert.True(res.FeePercentOfSent > 1);
@@ -1249,13 +1249,6 @@ namespace WalletWasabi.Tests
operations = new[] { new WalletService.Operation(scp, Money.Coins(0.5m), "") };
btx = await wallet.BuildTransactionAsync(password, operations, 2);
-
- operations = new[] { new WalletService.Operation(scp, Money.Coins(0.00005m), "") };
- btx = await wallet.BuildTransactionAsync(password, operations, 2, false, 0);
- Assert.True(btx.FeePercentOfSent > 20);
- Assert.Single(btx.SpentCoins);
- Assert.Equal(txid, btx.SpentCoins.First().TransactionId);
- Assert.False(btx.Transaction.Transaction.RBF);
}
finally
{
@@ -1681,8 +1674,8 @@ namespace WalletWasabi.Tests
{
// Never changes.
Assert.True(0 < rs.RoundId);
- Assert.Equal(Money.Coins(0.00000544m), rs.FeePerInputs);
- Assert.Equal(Money.Coins(0.00000264m), rs.FeePerOutputs);
+ Assert.Equal(Money.Coins(0.00009792m), rs.FeePerInputs);
+ Assert.Equal(Money.Coins(0.00004752m), rs.FeePerOutputs);
Assert.Equal(7, rs.MaximumInputCountPerPeer);
// Changes per rounds.
Assert.Equal(denomination, rs.Denomination);

MODIFY
WalletWasabi/Extensions/RPCClientExtensions.cs
WalletWasabi/Extensions/RPCClientExtensions.cs
@@ -53,14 +53,16 @@ namespace NBitcoin.RPC
int staoshiPerBytes;
if (estimateMode == EstimateSmartFeeMode.Conservative)
{
- staoshiPerBytes = 6 + confirmationTarget;
+ staoshiPerBytes = ((1008 + 1 + 6) - confirmationTarget) / 7;
}
else // Economical
{
- staoshiPerBytes = 5 + confirmationTarget;
+ staoshiPerBytes = ((1008 + 1 + 5) - confirmationTarget) / 7;
}
- var resp = new EstimateSmartFeeResponse { Blocks = confirmationTarget, FeeRate = new FeeRate(new Money(staoshiPerBytes * 1000, MoneyUnit.Satoshi)) };
+ Money feePerK = new Money(staoshiPerBytes * 1000, MoneyUnit.Satoshi);
+ FeeRate feeRate = new FeeRate(feePerK);
+ var resp = new EstimateSmartFeeResponse { Blocks = confirmationTarget, FeeRate = feeRate };
return resp;
}
}

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -755,7 +755,7 @@ namespace WalletWasabi.Services
if (realToSend[i].amount < Money.Zero)
{
- throw new InsufficientBalanceException(Money.Zero, realToSend[i].amount);
+ throw new InsufficientBalanceException(fee + 1, realToSend[i].amount + fee);
}
}

Fix RegTest Fee estimation simulation