Mark destinations used when CJ successfully finished
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
+using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Helpers;
@@ -63,6 +64,7 @@ public class CoinJoinClient
public bool ConsolidationMode { get; private set; }
private TimeSpan FeeRateMedianTimeFrame { get; }
+ public IEnumerable<IDestination> Destinations { get; private set; }
private async Task<RoundState> WaitForRoundAsync(CancellationToken token)
{
@@ -169,8 +171,8 @@ public class CoinJoinClient
var outputValues = amountDecomposer.Decompose(registeredCoinEffectiveValues, theirCoinEffectiveValues);
// Get as many destinations as outputs we need.
- var destinations = DestinationProvider.GetNextDestinations(outputValues.Count()).ToArray();
- var outputTxOuts = outputValues.Zip(destinations, (amount, destination) => new TxOut(amount, destination.ScriptPubKey));
+ Destinations = DestinationProvider.GetNextDestinations(outputValues.Count()).ToArray();
+ var outputTxOuts = outputValues.Zip(Destinations, (amount, destination) => new TxOut(amount, destination.ScriptPubKey));
DependencyGraph dependencyGraph = DependencyGraph.ResolveCredentialDependencies(inputEffectiveValuesAndSizes, outputTxOuts, roundState.FeeRate, roundState.CoordinationFeeRate, roundState.MaxVsizeAllocationPerAlice);
DependencyGraphTaskScheduler scheduler = new(dependencyGraph);

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
@@ -6,6 +6,7 @@ using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Logging;
using WalletWasabi.Models;
@@ -171,6 +172,10 @@ public class CoinJoinManager : BackgroundService
if (success)
{
CoinRefrigerator.Freeze(finishedCoinJoin.CoinCandidates);
+ foreach (var k in finishedCoinJoin.Wallet.KeyManager.GetKeys(x => finishedCoinJoin.Destinations.Select(x => x.ScriptPubKey).Contains(x.P2wpkhScript)))
+ {
+ k.SetKeyState(KeyState.Used);
+ }
Logger.LogInfo($"{logPrefix} finished!");
}
else

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinTracker.cs
WalletWasabi/WabiSabi/Client/CoinJoinTracker.cs
+using NBitcoin;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Wallets;
@@ -29,6 +31,7 @@ public class CoinJoinTracker : IDisposable
public Wallet Wallet { get; }
public Task<bool> CoinJoinTask { get; }
public IEnumerable<SmartCoin> CoinCandidates { get; }
+ public IEnumerable<IDestination> Destinations => CoinJoinClient.Destinations;
public bool IsCompleted => CoinJoinTask.IsCompleted;
public bool InCriticalCoinJoinState => CoinJoinClient.InCriticalCoinJoinState;

Mark destinations used when CJ successfully finished