Always try to register confirmed coins first
Resolves
MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
@@ -150,12 +150,45 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
{
lock (StateLock)
{
+ if (!WaitingList.Any()) // To avoid computations.
+ {
+ return Enumerable.Empty<(uint256 txid, uint index)>();
+ }
+
Money amountNeededExceptInputFees = denomination + (feePerOutputs * 2);
+ var confirmedResult = GetRegistrableCoinsNoLock(maximumInputCountPerPeer, feePerInputs, amountNeededExceptInputFees, allowUnconfirmedZeroLink: false);
+ if (confirmedResult.Any())
+ {
+ return confirmedResult;
+ }
+ else
+ {
+ return GetRegistrableCoinsNoLock(maximumInputCountPerPeer, feePerInputs, amountNeededExceptInputFees, allowUnconfirmedZeroLink: true);
+ }
+ }
+ }
+
+ private IEnumerable<(uint256 txid, uint index)> GetRegistrableCoinsNoLock(int maximumInputCountPerPeer, Money feePerInputs, Money amountNeededExceptInputFees, bool allowUnconfirmedZeroLink)
+ {
+ if (!WaitingList.Any()) // To avoid computations.
+ {
+ return Enumerable.Empty<(uint256 txid, uint index)>();
+ }
+
+ Func<SmartCoin, bool> confirmationPredicate;
+ if (allowUnconfirmedZeroLink)
+ {
+ confirmationPredicate = x => x.Confirmed || x.Label.StartsWith("ZeroLink", StringComparison.Ordinal);
+ }
+ else
+ {
+ confirmationPredicate = x => x.Confirmed;
+ }
var coins = WaitingList
.Where(x => x.Value <= DateTimeOffset.UtcNow)
.Select(x => x.Key) // Only if registering coins is already allowed.
- .Where(x => x.Confirmed || x.Label.StartsWith("ZeroLink", StringComparison.Ordinal));
+ .Where(confirmationPredicate);
for (int i = 1; i <= maximumInputCountPerPeer; i++) // The smallest number of coins we can register the better it is.
{
@@ -173,7 +206,6 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
return Enumerable.Empty<(uint256 txid, uint index)>(); // Inputs are too small, max input to be registered is reached.
}
- }
public IEnumerable<long> GetActivelyMixingRounds()
{

Always try to register confirmed coins first
Resolves https://github.com/zkSNACKs/WalletWasabi/issues/923