diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 0cd9037..d92a469 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -318,10 +318,10 @@ public class Wallet { //Add change output transaction.addOutput(changeAmt, getOutputScript(changeNode)); - return new WalletTransaction(this, transaction, selectedUtxos, recipientAddress, recipientAmount, changeNode, changeAmt, changeFeeRequiredAmt); + return new WalletTransaction(this, transaction, utxoSelectors, selectedUtxos, recipientAddress, recipientAmount, changeNode, changeAmt, changeFeeRequiredAmt); } - return new WalletTransaction(this, transaction, selectedUtxos, recipientAddress, recipientAmount, differenceAmt); + return new WalletTransaction(this, transaction, utxoSelectors, selectedUtxos, recipientAddress, recipientAmount, differenceAmt); } } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java index f3a7e72..e33988d 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java @@ -4,6 +4,7 @@ import com.sparrowwallet.drongo.address.Address; import com.sparrowwallet.drongo.protocol.Transaction; import com.sparrowwallet.drongo.psbt.PSBT; +import java.util.List; import java.util.Map; /** @@ -13,6 +14,7 @@ import java.util.Map; public class WalletTransaction { private final Wallet wallet; private final Transaction transaction; + private final List utxoSelectors; private final Map selectedUtxos; private final Address recipientAddress; private final long recipientAmount; @@ -20,13 +22,14 @@ public class WalletTransaction { private final long changeAmount; private final long fee; - public WalletTransaction(Wallet wallet, Transaction transaction, Map selectedUtxos, Address recipientAddress, long recipientAmount, long fee) { - this(wallet, transaction, selectedUtxos, recipientAddress, recipientAmount, null, 0L, fee); + public WalletTransaction(Wallet wallet, Transaction transaction, List utxoSelectors, Map selectedUtxos, Address recipientAddress, long recipientAmount, long fee) { + this(wallet, transaction, utxoSelectors, selectedUtxos, recipientAddress, recipientAmount, null, 0L, fee); } - public WalletTransaction(Wallet wallet, Transaction transaction, Map selectedUtxos, Address recipientAddress, long recipientAmount, WalletNode changeNode, long changeAmount, long fee) { + public WalletTransaction(Wallet wallet, Transaction transaction, List utxoSelectors, Map selectedUtxos, Address recipientAddress, long recipientAmount, WalletNode changeNode, long changeAmount, long fee) { this.wallet = wallet; this.transaction = transaction; + this.utxoSelectors = utxoSelectors; this.selectedUtxos = selectedUtxos; this.recipientAddress = recipientAddress; this.recipientAmount = recipientAmount; @@ -48,6 +51,10 @@ public class WalletTransaction { return transaction; } + public List getUtxoSelectors() { + return utxoSelectors; + } + public Map getSelectedUtxos() { return selectedUtxos; } @@ -83,4 +90,8 @@ public class WalletTransaction { public double getFeePercentage() { return (double)getFee() / getTotal(); } + + public boolean isCoinControlUsed() { + return !utxoSelectors.isEmpty() && utxoSelectors.get(0) instanceof PresetUtxoSelector; + } }