Skip to content
Permalink
Browse files

Use sanity check on coordinator fees.

Resolves #783
  • Loading branch information...
nopara73 committed Dec 3, 2018
1 parent 0ec1744 commit 05a6f64f087070690fedaaa941ce9134e875504c
Showing with 24 additions and 1 deletion.
  1. +8 −0 WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
  2. +16 −1 WalletWasabi/Services/CcjClient.cs
@@ -207,6 +207,14 @@ public CcjClientRound GetRegistrableRoundOrDefault()
}
}

public CcjClientRound GetLatestRoundOrDefault()
{
lock (StateLock)
{
return Rounds.LastOrDefault();
}
}

public CcjClientRound GetMostAdvancedRoundOrDefault()
{
lock (StateLock)
@@ -35,6 +35,8 @@ public class CcjClient
public Uri CcjHostUri { get; }
private IPEndPoint TorSocks5EndPoint { get; }

private decimal? CoordinatorFeepercentToCheck { get; set; }

/// <summary>
/// Used to avoid address reuse as much as possible but still not bloating the wallet.
/// </summary>
@@ -70,6 +72,7 @@ public CcjClient(Network network, BlindingRsaPubKey coordinatorPubKey, KeyManage
KeyManager = Guard.NotNull(nameof(keyManager), keyManager);
CcjHostUri = Guard.NotNull(nameof(ccjHostUri), ccjHostUri);
TorSocks5EndPoint = torSocks5EndPoint;
CoordinatorFeepercentToCheck = null;
SatoshiClient = new SatoshiClient(ccjHostUri, torSocks5EndPoint);

_running = 0;
@@ -176,7 +179,15 @@ private async Task ProcessStatusAsync(int minDelayReplySeconds, int maxDelayRepl
CcjClientRound registrableRound = State.GetRegistrableRoundOrDefault();
if (registrableRound != default)
{
if (!registrableRound.State.HaveEnoughQueued(State.GetAllQueuedCoinAmounts().ToArray()))
// If the coordinator increases fees, don't register. Let the users register manually again.
bool dequeueBecauseCoordinatorFeeChanged = false;
if (CoordinatorFeepercentToCheck != default)
{
dequeueBecauseCoordinatorFeeChanged = registrableRound.State.CoordinatorFeePercent > CoordinatorFeepercentToCheck;
}

if (!registrableRound.State.HaveEnoughQueued(State.GetAllQueuedCoinAmounts().ToArray())
|| dequeueBecauseCoordinatorFeeChanged)
{
await DequeueAllCoinsFromMixNoLockAsync();
}
@@ -669,6 +680,10 @@ public async Task<IEnumerable<SmartCoin>> QueueCoinsToMixAsync(string password,
{
await DequeueCoinsFromMixNoLockAsync(State.GetSpentCoins().ToArray());

// Every time the user enqueues (intentionally writes in password) then the coordinator fee percent must be noted and dequeue later if changes.
CcjClientRound latestRound = State.GetLatestRoundOrDefault();
CoordinatorFeepercentToCheck = latestRound?.State?.CoordinatorFeePercent;

var except = new List<SmartCoin>();

foreach (SmartCoin coin in coins)

0 comments on commit 05a6f64

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