move try catch block inside ChangelessCoinSelector
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionsFlyoutViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionsFlyoutViewModel.cs
@@ -54,8 +54,6 @@ public partial class PrivacySuggestionsFlyoutViewModel : ViewModelBase
var loadingRing = new LoadingSuggestionViewModel();
Suggestions.Add(loadingRing);
- try
- {
var hasChange = transaction.InnerWalletOutputs.Any(x => x.ScriptPubKey != destination.ScriptPubKey);
if (hasChange && !isFixedAmount && !info.IsPayJoin)
@@ -68,14 +66,7 @@ public partial class PrivacySuggestionsFlyoutViewModel : ViewModelBase
Suggestions.Insert(Suggestions.Count - 1, suggestion);
}
}
- }
- catch (OperationCanceledException)
- {
- Logger.LogWarning("Computing privacy suggestions was cancelled or timed out.");
- }
- finally
- {
+
Suggestions.Remove(loadingRing);
}
}
-}

MODIFY
WalletWasabi/Blockchain/TransactionBuilding/BranchAndBound.cs
WalletWasabi/Blockchain/TransactionBuilding/BranchAndBound.cs
@@ -111,7 +111,7 @@ public class BranchAndBound
// Micro optimization: Do not check cancellation token every time as it requires accessing volatile memory.
if (i % 10_000 == 0 && cancellationToken.IsCancellationRequested)
{
- return false;
+ cancellationToken.ThrowIfCancellationRequested();
}
}
while (depth >= 0);

MODIFY
WalletWasabi/Blockchain/TransactionBuilding/ChangelessTransactionCoinSelector.cs
WalletWasabi/Blockchain/TransactionBuilding/ChangelessTransactionCoinSelector.cs
@@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.TransactionBuilding.BnB;
using WalletWasabi.Blockchain.TransactionOutputs;
+using WalletWasabi.Logging;
namespace WalletWasabi.Blockchain.TransactionBuilding;
@@ -75,7 +76,17 @@ public static class ChangelessTransactionCoinSelector
BranchAndBound branchAndBound = new();
- var foundExactMatch = branchAndBound.TryGetMatch(strategy, out List<long>? solution, cancellationToken);
+ bool foundExactMatch = false;
+ List<long>? solution = null;
+
+ try
+ {
+ foundExactMatch = branchAndBound.TryGetMatch(strategy, out solution, cancellationToken);
+ }
+ catch (OperationCanceledException)
+ {
+ Logger.LogWarning("Computing privacy suggestions was cancelled or timed out.");
+ }
// If we've not found an optimal solution then we will use the best.
if (!foundExactMatch && strategy.GetBestSelectionFound() is long[] bestSolution)

move try catch block inside ChangelessCoinSelector