Set starting anonymity set for tumbler
MODIFY
HiddenWallet.ChaumianTumbler/Configuration/Config.cs
HiddenWallet.ChaumianTumbler/Configuration/Config.cs
@@ -44,6 +44,9 @@ namespace HiddenWallet.ChaumianTumbler.Configuration
[JsonProperty(PropertyName = "MaximumAnonymitySet")]
public int? MaximumAnonymitySet { get; private set; }
+ [JsonProperty(PropertyName = "StartingAnonymitySet")]
+ public int? StartingAnonymitySet { get; private set; }
+
[JsonProperty(PropertyName = "AverageInputRegistrationTimeInSeconds")]
public int? AverageTimeToSpendInInputRegistrationInSeconds { get; private set; }
@@ -70,7 +73,7 @@ namespace HiddenWallet.ChaumianTumbler.Configuration
[JsonProperty(PropertyName = "FeeEstimationMode")]
[JsonConverter(typeof(EstimateSmartFeeModeConverter))]
- public EstimateSmartFeeMode FeeEstimationMode { get; private set; }
+ public EstimateSmartFeeMode? FeeEstimationMode { get; private set; }
public Config()
{
@@ -100,6 +103,7 @@ namespace HiddenWallet.ChaumianTumbler.Configuration
DenominationBTC = new Money(1m, MoneyUnit.BTC);
MinimumAnonymitySet = 3;
MaximumAnonymitySet = 100; // for now, in theory 300-400 should be fine, too
+ StartingAnonymitySet = 7;
AverageTimeToSpendInInputRegistrationInSeconds = 180; // 3min
InputRegistrationPhaseTimeoutInSeconds = 86400; // one day
ConnectionConfirmationPhaseTimeoutInSeconds = 60;
@@ -107,8 +111,8 @@ namespace HiddenWallet.ChaumianTumbler.Configuration
SigningPhaseTimeoutInSeconds = 60;
MaximumInputsPerAlices = 7;
FallBackSatoshiFeePerBytes = 300;
- FeeConfirmationTarget = 2;
- FeeEstimationMode = EstimateSmartFeeMode.Economical;
+ FeeConfirmationTarget = 144;
+ FeeEstimationMode = EstimateSmartFeeMode.Conservative;
if (!File.Exists(path))
{
@@ -127,6 +131,7 @@ namespace HiddenWallet.ChaumianTumbler.Configuration
DenominationBTC = config.DenominationBTC ?? DenominationBTC;
MinimumAnonymitySet = config.MinimumAnonymitySet ?? MinimumAnonymitySet;
MaximumAnonymitySet = config.MaximumAnonymitySet ?? MaximumAnonymitySet;
+ StartingAnonymitySet = config.StartingAnonymitySet ?? StartingAnonymitySet;
AverageTimeToSpendInInputRegistrationInSeconds = config.AverageTimeToSpendInInputRegistrationInSeconds ?? AverageTimeToSpendInInputRegistrationInSeconds;
InputRegistrationPhaseTimeoutInSeconds = config.InputRegistrationPhaseTimeoutInSeconds ?? InputRegistrationPhaseTimeoutInSeconds;
ConnectionConfirmationPhaseTimeoutInSeconds = config.ConnectionConfirmationPhaseTimeoutInSeconds ?? ConnectionConfirmationPhaseTimeoutInSeconds;
@@ -135,7 +140,7 @@ namespace HiddenWallet.ChaumianTumbler.Configuration
MaximumInputsPerAlices = config.MaximumInputsPerAlices ?? MaximumInputsPerAlices;
FallBackSatoshiFeePerBytes = config.FallBackSatoshiFeePerBytes ?? FallBackSatoshiFeePerBytes;
FeeConfirmationTarget = config.FeeConfirmationTarget ?? FeeConfirmationTarget;
- FeeEstimationMode = config.FeeEstimationMode;
+ FeeEstimationMode = config.FeeEstimationMode ?? FeeEstimationMode;
}
await ToFileAsync(path, cancel);

MODIFY
HiddenWallet.ChaumianTumbler/Global.cs
HiddenWallet.ChaumianTumbler/Global.cs
@@ -118,7 +118,7 @@ namespace HiddenWallet.ChaumianTumbler
throw new NotSupportedException("blocks != headers");
}
- var estimateSmartFeeResponse = await RpcClient.TryEstimateSmartFeeAsync((int)Global.Config.FeeConfirmationTarget, Global.Config.FeeEstimationMode);
+ var estimateSmartFeeResponse = await RpcClient.TryEstimateSmartFeeAsync((int)Global.Config.FeeConfirmationTarget, (EstimateSmartFeeMode)Global.Config.FeeEstimationMode);
if (estimateSmartFeeResponse == null) throw new NotSupportedException($"estimatesmartfee {Config.FeeConfirmationTarget} {Config.FeeEstimationMode} == null");
}
catch

MODIFY
HiddenWallet.ChaumianTumbler/TumblerStateMachine.cs
HiddenWallet.ChaumianTumbler/TumblerStateMachine.cs
@@ -26,8 +26,8 @@ namespace HiddenWallet.ChaumianTumbler
public Money Denomination { get; private set; }
public Money FeePerInputs { get; private set; }
public Money FeePerOutputs { get; private set; }
- public int AnonymitySet { get; private set; } = (int)Global.Config.MinimumAnonymitySet;
- public TimeSpan TimeSpentInInputRegistration { get; private set; } = TimeSpan.FromSeconds((int)Global.Config.AverageTimeToSpendInInputRegistrationInSeconds) + TimeSpan.FromSeconds(1); // took one sec longer, so the first round will use the same anonymity set
+ public int AnonymitySet { get; private set; } = (int)Global.Config.StartingAnonymitySet;
+ public TimeSpan TimeSpentInInputRegistration { get; private set; } = TimeSpan.FromSeconds((int)Global.Config.AverageTimeToSpendInInputRegistrationInSeconds);
public volatile bool AcceptRequest;
public Stopwatch InputRegistrationStopwatch { get; private set; }
public volatile bool FallBackRound;
@@ -235,7 +235,12 @@ namespace HiddenWallet.ChaumianTumbler
var min = (int)Global.Config.MinimumAnonymitySet;
var max = (int)Global.Config.MaximumAnonymitySet;
// If the previous non-fallback Input Registration phase took more than three minutes
- if (TimeSpentInInputRegistration > TimeSpan.FromSeconds((int)Global.Config.AverageTimeToSpendInInputRegistrationInSeconds))
+ if(TimeSpentInInputRegistration == TimeSpan.FromSeconds((int)Global.Config.AverageTimeToSpendInInputRegistrationInSeconds))
+ {
+ var tmpAnonSet = Math.Min(max, AnonymitySet);
+ AnonymitySet = Math.Max(min, tmpAnonSet);
+ }
+ else if (TimeSpentInInputRegistration > TimeSpan.FromSeconds((int)Global.Config.AverageTimeToSpendInInputRegistrationInSeconds))
{
// decrement this round's desired anonymity set relative to the previous desired anonymity set,
var tmpAnonSet = Math.Max(min, AnonymitySet - 1);
@@ -293,7 +298,7 @@ namespace HiddenWallet.ChaumianTumbler
try
{
- var estimateSmartFeeResponse = await Global.RpcClient.TryEstimateSmartFeeAsync((int)Global.Config.FeeConfirmationTarget, Global.Config.FeeEstimationMode);
+ var estimateSmartFeeResponse = await Global.RpcClient.TryEstimateSmartFeeAsync((int)Global.Config.FeeConfirmationTarget, (EstimateSmartFeeMode)Global.Config.FeeEstimationMode);
if (estimateSmartFeeResponse == null) throw new InvalidOperationException("FeeRate is not yet initialized");
var feeRate = estimateSmartFeeResponse.FeeRate;
Money feePerBytes = (feeRate.FeePerK / 1000);

MODIFY
HiddenWallet/Converters/EstimateSmartFeeModeConverter.cs
HiddenWallet/Converters/EstimateSmartFeeModeConverter.cs
@@ -11,13 +11,18 @@ namespace HiddenWallet.Converters
/// <inheritdoc />
public override bool CanConvert(Type objectType)
{
- return objectType == typeof(EstimateSmartFeeMode);
+
+ return objectType == typeof(EstimateSmartFeeMode) || objectType == typeof(EstimateSmartFeeMode?);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
// check additional strings those are not checked by GetNetwork
string value = ((string)reader.Value).Trim();
+ if(string.IsNullOrWhiteSpace(value) || value.Equals("null", StringComparison.OrdinalIgnoreCase))
+ {
+ return null;
+ }
if(EstimateSmartFeeMode.Conservative.ToString().Equals(value, StringComparison.OrdinalIgnoreCase))
{
return EstimateSmartFeeMode.Conservative;
@@ -33,7 +38,7 @@ namespace HiddenWallet.Converters
/// <inheritdoc />
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
- writer.WriteValue(((EstimateSmartFeeMode)value).ToString());
+ writer.WriteValue(((EstimateSmartFeeMode?)value).ToString());
}
}
}

Set starting anonymity set for tumbler