Skip to content
Permalink
Browse files

Remove currentdenom, (so denom gets serialized)

  • Loading branch information...
nopara73 committed Nov 27, 2018
1 parent c922c60 commit e274957a3772fdfad1e3af450f2a2a5384bca318
@@ -1697,19 +1697,19 @@ public async Task CcjTestsAsync()
httpRequestException = await Assert.ThrowsAsync<HttpRequestException>(async () => await AliceClient.CreateNewAsync(network, inputsRequest, baseUri));
Assert.StartsWith($"{HttpStatusCode.BadRequest.ToReasonString()}\nNot enough inputs are provided. Fee to pay:", httpRequestException.Message);

roundConfig.SetDenomination(Money.Coins(0.01m)); // exactly the same as our output
roundConfig.Denomination = Money.Coins(0.01m); // exactly the same as our output
coordinator.UpdateRoundConfig(roundConfig);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
httpRequestException = await Assert.ThrowsAsync<HttpRequestException>(async () => await AliceClient.CreateNewAsync(network, inputsRequest, baseUri));
Assert.StartsWith($"{HttpStatusCode.BadRequest.ToReasonString()}\nNot enough inputs are provided. Fee to pay:", httpRequestException.Message);

roundConfig.SetDenomination(Money.Coins(0.00999999m)); // one satoshi less than our output
roundConfig.Denomination = Money.Coins(0.00999999m); // one satoshi less than our output
coordinator.UpdateRoundConfig(roundConfig);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
httpRequestException = await Assert.ThrowsAsync<HttpRequestException>(async () => await AliceClient.CreateNewAsync(network, inputsRequest, baseUri));
Assert.StartsWith($"{HttpStatusCode.BadRequest.ToReasonString()}\nNot enough inputs are provided. Fee to pay:", httpRequestException.Message);

roundConfig.SetDenomination(Money.Coins(0.008m)); // one satoshi less than our output
roundConfig.Denomination = Money.Coins(0.008m); // one satoshi less than our output
roundConfig.ConnectionConfirmationTimeout = 2;
coordinator.UpdateRoundConfig(roundConfig);
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
@@ -2545,7 +2545,7 @@ public async Task Ccj100ParticipantsTestsAsync()
Assert.True(2 * feeRateReal.FeePerK > feeRateTx.FeePerK); // Max 200% mistake.

var activeOutput = finalCoinjoin.GetIndistinguishableOutputs().OrderByDescending(x => x.count).First();
Assert.True(activeOutput.value >= roundConfig.CurrentDenomination);
Assert.True(activeOutput.value >= roundConfig.Denomination);
Assert.True(activeOutput.value >= roundConfig.AnonymitySet);

foreach (var aliceClient in aliceClients)
@@ -131,7 +131,7 @@ public CcjRound(RPCClient rpc, UtxoReferee utxoReferee, CcjRoundConfig config)
UtxoReferee = Guard.NotNull(nameof(utxoReferee), utxoReferee);
Guard.NotNull(nameof(config), config);

Denomination = config.CurrentDenomination;
Denomination = config.Denomination;
ConfirmationTarget = (int)config.ConfirmationTarget;
CoordinatorFeePercent = (decimal)config.CoordinatorFeePercent;
AnonymitySet = (int)config.AnonymitySet;
@@ -14,32 +14,12 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
[JsonObject(MemberSerialization.OptIn)]
public class CcjRoundConfig : IConfig
{
private Money _denomination;

/// <inheritdoc />
public string FilePath { get; internal set; }

public Money CurrentDenomination { get; internal set; }

[JsonProperty(PropertyName = "Denomination")]
[JsonConverter(typeof(MoneyBtcJsonConverter))]
private Money Denomination
{
get => _denomination;
set
{
if (value != _denomination)
{
_denomination = value;
CurrentDenomination = value;
}
}
}

internal void SetDenomination(Money denomination)
{
Denomination = denomination;
}
public Money Denomination { get; internal set; }

[JsonProperty(PropertyName = "ConfirmationTarget")]
public int? ConfirmationTarget { get; internal set; }
@@ -240,11 +240,12 @@ private async void Round_StatusChangedAsync(object sender, CcjRoundStatus status
feePerOutputs = fees.feePerOutputs;

Money newDenominationToGetInWithactiveOutputs = activeOutputAmount - (feePerInputs + 2 * feePerOutputs);
if (newDenominationToGetInWithactiveOutputs < RoundConfig.CurrentDenomination)
if (newDenominationToGetInWithactiveOutputs < RoundConfig.Denomination)
{
if (newDenominationToGetInWithactiveOutputs > Money.Coins(0.01m))
{
RoundConfig.CurrentDenomination = newDenominationToGetInWithactiveOutputs;
RoundConfig.Denomination = newDenominationToGetInWithactiveOutputs;
await RoundConfig.ToFileAsync();
}
}
}

0 comments on commit e274957

Please sign in to comment.
You can’t perform that action at this time.