diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/InsufficientFundsException.java b/src/main/java/com/sparrowwallet/drongo/wallet/InsufficientFundsException.java index dca047e..3229edf 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/InsufficientFundsException.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/InsufficientFundsException.java @@ -1,6 +1,8 @@ package com.sparrowwallet.drongo.wallet; public class InsufficientFundsException extends Exception { + private Long targetValue; + public InsufficientFundsException() { super(); } @@ -8,4 +10,13 @@ public class InsufficientFundsException extends Exception { public InsufficientFundsException(String msg) { super(msg); } + + public InsufficientFundsException(String message, Long targetValue) { + super(message); + this.targetValue = targetValue; + } + + public Long getTargetValue() { + return targetValue; + } } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/PresetUtxoSelector.java b/src/main/java/com/sparrowwallet/drongo/wallet/PresetUtxoSelector.java index 090014c..996fd17 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/PresetUtxoSelector.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/PresetUtxoSelector.java @@ -7,15 +7,22 @@ import java.util.stream.Collectors; public class PresetUtxoSelector extends SingleSetUtxoSelector { private final Collection presetUtxos; + private final Collection excludedUtxos; private final boolean maintainOrder; public PresetUtxoSelector(Collection presetUtxos) { + this(presetUtxos, new ArrayList<>()); + } + + public PresetUtxoSelector(Collection presetUtxos, Collection excludedUtxos) { this.presetUtxos = presetUtxos; + this.excludedUtxos = excludedUtxos; this.maintainOrder = false; } public PresetUtxoSelector(Collection presetUtxos, boolean maintainOrder) { this.presetUtxos = presetUtxos; + this.excludedUtxos = new ArrayList<>(); this.maintainOrder = maintainOrder; } @@ -44,6 +51,10 @@ public class PresetUtxoSelector extends SingleSetUtxoSelector { return presetUtxos; } + public Collection getExcludedUtxos() { + return excludedUtxos; + } + @Override public boolean shuffleInputs() { return !maintainOrder; diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 5e13524..d828cc8 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -1224,7 +1224,7 @@ public class Wallet extends Persistable implements Comparable { } } - throw new InsufficientFundsException("Not enough combined value in UTXOs for output value " + targetValue); + throw new InsufficientFundsException("Not enough combined value in UTXOs for output value " + targetValue, targetValue); } private List getGroupedUtxos(List utxoFilters, double feeRate, double longTermFeeRate, boolean groupByAddress, boolean includeSpentMempoolOutputs) {