Add SevenDaysConfirmationTarget (1008) as const
MODIFY
WalletWasabi.Backend/Controllers/BlockchainController.cs
WalletWasabi.Backend/Controllers/BlockchainController.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Threading.Tasks;
using WalletWasabi.Backend.Models;
using WalletWasabi.Backend.Models.Responses;
+using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Models;
@@ -61,7 +62,7 @@ namespace WalletWasabi.Backend.Controllers
{
if (int.TryParse(targetParam, out var target))
{
- if (target < 2 || target > 1008)
+ if (target < 2 || target > Constants.SevenDaysConfirmationTarget)
{
return BadRequest("All requested confirmation target must be >=2 AND <= 1008.");
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -572,7 +572,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
var h = feeTarget / 6;
ConfirmationExpectedText = $"{h} {IfPlural(h, "hour", "hours")}";
}
- else if (feeTarget >= 145 && feeTarget < 1008) // days
+ else if (feeTarget >= 145 && feeTarget < Constants.SevenDaysConfirmationTarget) // days
{
var d = feeTarget / 144;
ConfirmationExpectedText = $"{d} {IfPlural(d, "day", "days")}";
@@ -713,7 +713,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
else
{
MinimumFeeTarget = 2;
- MaximumFeeTarget = 1008;
+ MaximumFeeTarget = Constants.SevenDaysConfirmationTarget;
}
}

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -836,7 +836,7 @@ namespace WalletWasabi.Tests
Script receive = wallet.GetReceiveKey("Basic").P2wpkhScript;
Money amountToSend = wallet.Coins.Where(x => !x.Unavailable).Sum(x => x.Amount) / 2;
- var res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, 1008, allowUnconfirmed: true);
+ var res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, Constants.SevenDaysConfirmationTarget, allowUnconfirmed: true);
foreach (SmartCoin coin in res.SpentCoins)
{
@@ -884,7 +884,7 @@ namespace WalletWasabi.Tests
receive = wallet.GetReceiveKey("SubtractFeeFromAmount").P2wpkhScript;
amountToSend = wallet.Coins.Where(x => !x.Unavailable).Sum(x => x.Amount) / 3;
- res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, 1008, allowUnconfirmed: true, subtractFeeFromAmountIndex: 0);
+ res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, Constants.SevenDaysConfirmationTarget, allowUnconfirmed: true, subtractFeeFromAmountIndex: 0);
Assert.Equal(2, res.InnerWalletOutputs.Count());
Assert.Empty(res.OuterWalletOutputs);
@@ -917,7 +917,7 @@ namespace WalletWasabi.Tests
#region LowFee
- res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, 1008, allowUnconfirmed: true);
+ res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, amountToSend, "foo") }, Constants.SevenDaysConfirmationTarget, allowUnconfirmed: true);
Assert.Equal(2, res.InnerWalletOutputs.Count());
Assert.Empty(res.OuterWalletOutputs);
@@ -1022,7 +1022,7 @@ namespace WalletWasabi.Tests
#region MaxAmount
receive = wallet.GetReceiveKey("MaxAmount").P2wpkhScript;
- res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, 1008, allowUnconfirmed: true);
+ res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, Constants.SevenDaysConfirmationTarget, allowUnconfirmed: true);
Assert.Single(res.InnerWalletOutputs);
Assert.Empty(res.OuterWalletOutputs);
@@ -1050,7 +1050,7 @@ namespace WalletWasabi.Tests
receive = wallet.GetReceiveKey("InputSelection").P2wpkhScript;
var inputCountBefore = res.SpentCoins.Count();
- res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, 1008,
+ res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, Constants.SevenDaysConfirmationTarget,
allowUnconfirmed: true,
allowedInputs: wallet.Coins.Where(x => !x.Unavailable).Select(x => new TxoRef(x.TransactionId, x.Index)).Take(1));
@@ -1070,7 +1070,7 @@ namespace WalletWasabi.Tests
Assert.Single(res.Transaction.Transaction.Outputs);
- res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, 1008,
+ res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "foo") }, Constants.SevenDaysConfirmationTarget,
allowUnconfirmed: true,
allowedInputs: new[] { res.SpentCoins.Select(x => new TxoRef(x.TransactionId, x.Index)).First() });
@@ -1086,7 +1086,7 @@ namespace WalletWasabi.Tests
#region Labeling
- res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "my label") }, 1008,
+ res = wallet.BuildTransaction(password, new[] { new WalletService.Operation(receive, Money.Zero, "my label") }, Constants.SevenDaysConfirmationTarget,
allowUnconfirmed: true);
Assert.Single(res.InnerWalletOutputs);
@@ -1096,7 +1096,7 @@ namespace WalletWasabi.Tests
res = wallet.BuildTransaction(password, new[] {
new WalletService.Operation(new Key().ScriptPubKey, amountToSend, "outgoing"),
new WalletService.Operation(new Key().ScriptPubKey, amountToSend, "outgoing2")
- }, 1008,
+ }, Constants.SevenDaysConfirmationTarget,
allowUnconfirmed: true);
Assert.Single(res.InnerWalletOutputs);
@@ -1270,12 +1270,12 @@ namespace WalletWasabi.Tests
var toSendWithTwoZeros = new[]{
new WalletService.Operation(scp, Money.Zero, "zero"),
new WalletService.Operation(scp, Money.Zero, "zero") };
- Assert.Throws<ArgumentException>(() => wallet.BuildTransaction(password, toSendWithTwoZeros, 1008, false));
+ Assert.Throws<ArgumentException>(() => wallet.BuildTransaction(password, toSendWithTwoZeros, Constants.SevenDaysConfirmationTarget, false));
// cannot specify spend all and custom change
var spendAll = new[]{
new WalletService.Operation(scp, Money.Zero, "spendAll") };
- Assert.Throws<ArgumentException>(() => wallet.BuildTransaction(password, spendAll, 1008, false, customChange: new Key().ScriptPubKey));
+ Assert.Throws<ArgumentException>(() => wallet.BuildTransaction(password, spendAll, Constants.SevenDaysConfirmationTarget, false, customChange: new Key().ScriptPubKey));
// Get some money, make it confirm.
var key = wallet.GetReceiveKey("foo label");

MODIFY
WalletWasabi/Extensions/RPCClientExtensions.cs
WalletWasabi/Extensions/RPCClientExtensions.cs
@@ -52,7 +52,7 @@ namespace NBitcoin.RPC
{
Logger.LogTrace<RPCClient>(ex);
// Hopefully Bitcoin Core brainfart: https://github.com/bitcoin/bitcoin/issues/14431
- for (int i = 2; i <= 1008; i++)
+ for (int i = 2; i <= Constants.SevenDaysConfirmationTarget; i++)
{
try
{
@@ -87,7 +87,7 @@ namespace NBitcoin.RPC
else
{
// Hopefully Bitcoin Core brainfart: https://github.com/bitcoin/bitcoin/issues/14431
- for (int i = 2; i <= 1008; i++)
+ for (int i = 2; i <= Constants.SevenDaysConfirmationTarget; i++)
{
response = await rpc.TryEstimateSmartFeeAsync(i, estimateMode);
if (response != null)
@@ -107,11 +107,11 @@ namespace NBitcoin.RPC
int satoshiPerBytes;
if (estimateMode == EstimateSmartFeeMode.Conservative)
{
- satoshiPerBytes = ((1008 + 1 + 6) - confirmationTarget) / 7;
+ satoshiPerBytes = ((Constants.SevenDaysConfirmationTarget + 1 + 6) - confirmationTarget) / 7;
}
else // Economical
{
- satoshiPerBytes = ((1008 + 1 + 5) - confirmationTarget) / 7;
+ satoshiPerBytes = ((Constants.SevenDaysConfirmationTarget + 1 + 5) - confirmationTarget) / 7;
}
Money feePerK = new Money(satoshiPerBytes * 1000, MoneyUnit.Satoshi);
@@ -122,7 +122,7 @@ namespace NBitcoin.RPC
public static async Task<AllFeeEstimate> EstimateAllFeeAsync(this RPCClient rpc, EstimateSmartFeeMode estimateMode = EstimateSmartFeeMode.Conservative, bool simulateIfRegTest = false, bool tolerateBitcoinCoreBrainfuck = true)
{
- var estimations = await rpc.EstimateHalfFeesAsync(new Dictionary<int, int>(), 2, 0, 1008, 0, estimateMode, simulateIfRegTest, tolerateBitcoinCoreBrainfuck);
+ var estimations = await rpc.EstimateHalfFeesAsync(new Dictionary<int, int>(), 2, 0, Constants.SevenDaysConfirmationTarget, 0, estimateMode, simulateIfRegTest, tolerateBitcoinCoreBrainfuck);
var allFeeEstimate = new AllFeeEstimate(estimateMode, estimations);
return allFeeEstimate;
}

MODIFY
WalletWasabi/Helpers/Constants.cs
WalletWasabi/Helpers/Constants.cs
@@ -73,5 +73,7 @@ namespace WalletWasabi.Helpers
public const string ChangeOfSpecialLabelStart = "change of (";
public const string ChangeOfSpecialLabelEnd = ")";
public const int BigFileReadWriteBufferSize = 1 * 1024 * 1024;
+
+ public const int SevenDaysConfirmationTarget = 1008;
}
}

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -1073,7 +1073,7 @@ namespace WalletWasabi.Services
{
throw new ArgumentException($"{nameof(customChange)} and send all to destination cannot be specified the same time.");
}
- Guard.InRangeAndNotNull(nameof(feeTarget), feeTarget, 0, 1008); // Allow 0 and 1, and correct later.
+ Guard.InRangeAndNotNull(nameof(feeTarget), feeTarget, 0, Constants.SevenDaysConfirmationTarget); // Allow 0 and 1, and correct later.
if (feeTarget < 2) // Correct 0 and 1 to 2.
{
feeTarget = 2;

Add SevenDaysConfirmationTarget (1008) as const