Select coins from reused address
MODIFY
WalletWasabi/Blockchain/TransactionOutputs/ISmartCoin.cs
WalletWasabi/Blockchain/TransactionOutputs/ISmartCoin.cs
using NBitcoin;
+using WalletWasabi.Blockchain.Keys;
namespace WalletWasabi.Blockchain.TransactionOutputs;
@@ -10,6 +11,8 @@ public interface ISmartCoin
/// <remarks>Note there might be a new script type that even NBitcoin does not support.</remarks>
ScriptType ScriptType { get; }
+ HdPubKey HdPubKey { get; }
+
double AnonymitySet { get; }
uint256 TransactionId { get; }

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -667,6 +667,20 @@ public class CoinJoinClient
return ImmutableList<TCoin>.Empty;
}
+ var sameAddressCoins = semiPrivateCoins
+ .Union(redCoins)
+ .GroupBy(x => x.HdPubKey)
+ .Select(x => x.ToList())
+ .Where(x => x.Count > 1)
+ .OrderBy(x => x.Count);
+
+ if (sameAddressCoins.Any())
+ {
+ // Select between 2 and MaxInputsRegistrableByWallet coins that are on reused HdPubKey.
+ // First from the max reused HdPubKey then complete with the 2nd max etc... until reaching max or no more coins on reused HdPubKey
+ return sameAddressCoins.SelectMany(group => group).Take(MaxInputsRegistrableByWallet).ToImmutableList();
+ }
+
Logger.LogDebug($"Coin selection started:");
Logger.LogDebug($"{nameof(filteredCoins)}: {filteredCoins.Length} coins, valued at {Money.Satoshis(filteredCoins.Sum(x => x.Amount)).ToString(false, true)} BTC.");
Logger.LogDebug($"{nameof(privateCoins)}: {privateCoins.Length} coins, valued at {Money.Satoshis(privateCoins.Sum(x => x.Amount)).ToString(false, true)} BTC.");

Select coins from reused address