make sure BnB uses coins from the same pockets
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/ChangeAvoidanceSuggestionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/ChangeAvoidanceSuggestionViewModel.cs
using NBitcoin;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.TransactionBuilding;
+using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Wallets;
@@ -41,16 +43,16 @@ public partial class ChangeAvoidanceSuggestionViewModel : SuggestionViewModel
public BuildTransactionResult TransactionResult { get; }
- public static async IAsyncEnumerable<ChangeAvoidanceSuggestionViewModel> GenerateSuggestionsAsync(
- TransactionInfo transactionInfo,
+ public static async IAsyncEnumerable<ChangeAvoidanceSuggestionViewModel> GenerateSuggestionsAsync(TransactionInfo transactionInfo,
BitcoinAddress destination,
Wallet wallet,
+ ImmutableArray<SmartCoin> coinsToUse,
int maxInputCount,
decimal usdExchangeRate,
[EnumeratorCancellation] CancellationToken cancellationToken)
{
var selections = ChangelessTransactionCoinSelector.GetAllStrategyResultsAsync(
- transactionInfo.Coins,
+ coinsToUse,
transactionInfo.FeeRate,
new TxOut(transactionInfo.Amount, destination),
maxInputCount,

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionsFlyoutViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionsFlyoutViewModel.cs
using NBitcoin;
using ReactiveUI;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
@@ -60,8 +61,13 @@ public partial class PrivacySuggestionsFlyoutViewModel : ViewModelBase
int originalInputCount = transaction.SpentCoins.Count();
int maxInputCount = (int)(Math.Max(3, originalInputCount * 1.3));
+ var pockets = wallet.GetPockets();
+ var spentCoins = transaction.SpentCoins;
+ var usedPockets = pockets.Where(x => x.Coins.Any(coin => spentCoins.Contains(coin)));
+ var coinsToUse = usedPockets.SelectMany(x => x.Coins).ToImmutableArray();
+
IAsyncEnumerable<ChangeAvoidanceSuggestionViewModel> suggestions =
- ChangeAvoidanceSuggestionViewModel.GenerateSuggestionsAsync(info, destination, wallet, maxInputCount, usdExchangeRate, linkedCts.Token);
+ ChangeAvoidanceSuggestionViewModel.GenerateSuggestionsAsync(info, destination, wallet, coinsToUse, maxInputCount, usdExchangeRate, linkedCts.Token);
await foreach (var suggestion in suggestions)
{

make sure BnB uses coins from the same pockets