diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/BnBUtxoSelector.java b/src/main/java/com/sparrowwallet/drongo/wallet/BnBUtxoSelector.java index 5132993..c3cacca 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/BnBUtxoSelector.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/BnBUtxoSelector.java @@ -34,7 +34,7 @@ public class BnBUtxoSelector implements UtxoSelector { return Collections.emptyList(); } - utxoPool.sort((a, b) -> (int)(b.getEffectiveValue() - a.getEffectiveValue())); + utxoPool.sort((a, b) -> Long.compare(b.getEffectiveValue(), a.getEffectiveValue())); long currentWasteValue = 0; ArrayDeque bestSelection = null; diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/KnapsackUtxoSelector.java b/src/main/java/com/sparrowwallet/drongo/wallet/KnapsackUtxoSelector.java index 2b02819..93c615f 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/KnapsackUtxoSelector.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/KnapsackUtxoSelector.java @@ -50,7 +50,7 @@ public class KnapsackUtxoSelector implements UtxoSelector { //We now have a list of UTXOs that are all smaller than the target + MIN_CHANGE, but together sum to greater than actualTargetValue // Solve subset sum by stochastic approximation - applicableGroups.sort((a, b) -> (int)(b.getEffectiveValue() - a.getEffectiveValue())); + applicableGroups.sort((a, b) -> Long.compare(b.getEffectiveValue(), a.getEffectiveValue())); boolean[] bestSelection = new boolean[applicableGroups.size()]; long bestValue = findApproximateBestSubset(applicableGroups, totalLower, actualTargetValue, bestSelection);