From 18075e06864085ad6c5aa26eb071ecb14e16b4e6 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 21 Apr 2021 09:37:19 +0200 Subject: [PATCH] improve variable naming for utxo selection criteria --- drongo | 2 +- .../sparrowwallet/sparrow/event/SpendUtxoEvent.java | 10 +++++----- .../java/com/sparrowwallet/sparrow/io/Config.java | 10 +++++----- .../preferences/GeneralPreferencesController.java | 8 ++++---- .../sparrow/wallet/HashIndexEntry.java | 2 +- .../sparrow/wallet/SendController.java | 13 ++++++------- .../sparrow/wallet/WalletTransactionsEntry.java | 2 +- .../sparrowwallet/sparrow/preferences/general.fxml | 2 +- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/drongo b/drongo index a25dfa5c..efaa6a06 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit a25dfa5c7671023b60d1773cf603b4d46885a546 +Subproject commit efaa6a066d2b7d7f982086060aa8f014ca89a190 diff --git a/src/main/java/com/sparrowwallet/sparrow/event/SpendUtxoEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/SpendUtxoEvent.java index 5a3944ad..0ae04620 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/SpendUtxoEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/SpendUtxoEvent.java @@ -11,18 +11,18 @@ public class SpendUtxoEvent { private final List utxos; private final List payments; private final Long fee; - private final boolean includeMempoolInputs; + private final boolean includeSpentMempoolOutputs; public SpendUtxoEvent(Wallet wallet, List utxos) { this(wallet, utxos, null, null, false); } - public SpendUtxoEvent(Wallet wallet, List utxos, List payments, Long fee, boolean includeMempoolInputs) { + public SpendUtxoEvent(Wallet wallet, List utxos, List payments, Long fee, boolean includeSpentMempoolOutputs) { this.wallet = wallet; this.utxos = utxos; this.payments = payments; this.fee = fee; - this.includeMempoolInputs = includeMempoolInputs; + this.includeSpentMempoolOutputs = includeSpentMempoolOutputs; } public Wallet getWallet() { @@ -41,7 +41,7 @@ public class SpendUtxoEvent { return fee; } - public boolean isIncludeMempoolInputs() { - return includeMempoolInputs; + public boolean isIncludeSpentMempoolOutputs() { + return includeSpentMempoolOutputs; } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index d5a958f1..f7231a59 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -28,7 +28,7 @@ public class Config { private boolean loadRecentWallets = true; private boolean validateDerivationPaths = true; private boolean groupByAddress = true; - private boolean includeMempoolChange = true; + private boolean includeMempoolOutputs = true; private boolean notifyNewTransactions = true; private boolean checkNewVersions = true; private Theme theme; @@ -183,12 +183,12 @@ public class Config { flush(); } - public boolean isIncludeMempoolChange() { - return includeMempoolChange; + public boolean isIncludeMempoolOutputs() { + return includeMempoolOutputs; } - public void setIncludeMempoolChange(boolean includeMempoolChange) { - this.includeMempoolChange = includeMempoolChange; + public void setIncludeMempoolOutputs(boolean includeMempoolOutputs) { + this.includeMempoolOutputs = includeMempoolOutputs; flush(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java index b68adf1b..cf5f255b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java @@ -43,7 +43,7 @@ public class GeneralPreferencesController extends PreferencesDetailController { private UnlabeledToggleSwitch groupByAddress; @FXML - private UnlabeledToggleSwitch includeMempoolChange; + private UnlabeledToggleSwitch includeMempoolOutputs; @FXML private UnlabeledToggleSwitch notifyNewTransactions; @@ -113,12 +113,12 @@ public class GeneralPreferencesController extends PreferencesDetailController { }); groupByAddress.setSelected(config.isGroupByAddress()); - includeMempoolChange.setSelected(config.isIncludeMempoolChange()); + includeMempoolOutputs.setSelected(config.isIncludeMempoolOutputs()); groupByAddress.selectedProperty().addListener((observableValue, oldValue, newValue) -> { config.setGroupByAddress(newValue); }); - includeMempoolChange.selectedProperty().addListener((observableValue, oldValue, newValue) -> { - config.setIncludeMempoolChange(newValue); + includeMempoolOutputs.selectedProperty().addListener((observableValue, oldValue, newValue) -> { + config.setIncludeMempoolOutputs(newValue); }); notifyNewTransactions.setSelected(config.isNotifyNewTransactions()); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java index 28acf37a..990463fd 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java @@ -59,7 +59,7 @@ public class HashIndexEntry extends Entry implements Comparable } public boolean isSpendable() { - return !isSpent() && (hashIndex.getHeight() > 0 || Config.get().isIncludeMempoolChange()) && (hashIndex.getStatus() == null || hashIndex.getStatus() != Status.FROZEN); + return !isSpent() && (hashIndex.getHeight() > 0 || Config.get().isIncludeMempoolOutputs()) && (hashIndex.getStatus() == null || hashIndex.getStatus() != Status.FROZEN); } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index f5bec9ff..31e84f30 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -44,7 +44,6 @@ import java.net.URL; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; public class SendController extends WalletFormController implements Initializable { @@ -128,7 +127,7 @@ public class SendController extends WalletFormController implements Initializabl private final StringProperty utxoLabelSelectionProperty = new SimpleStringProperty(""); - private final BooleanProperty includeMempoolInputsProperty = new SimpleBooleanProperty(false); + private final BooleanProperty includeSpentMempoolOutputsProperty = new SimpleBooleanProperty(false); private final ChangeListener feeListener = new ChangeListener<>() { @Override @@ -480,9 +479,9 @@ public class SendController extends WalletFormController implements Initializabl Long userFee = userFeeSet.get() ? getFeeValueSats() : null; Integer currentBlockHeight = AppServices.getCurrentBlockHeight(); boolean groupByAddress = Config.get().isGroupByAddress(); - boolean includeMempoolChange = Config.get().isIncludeMempoolChange(); - boolean includeMempoolInputs = includeMempoolInputsProperty.get(); - WalletTransaction walletTransaction = wallet.createWalletTransaction(getUtxoSelectors(), getUtxoFilters(), payments, getFeeRate(), getMinimumFeeRate(), userFee, currentBlockHeight, groupByAddress, includeMempoolChange, includeMempoolInputs); + boolean includeMempoolOutputs = Config.get().isIncludeMempoolOutputs(); + boolean includeSpentMempoolOutputs = includeSpentMempoolOutputsProperty.get(); + WalletTransaction walletTransaction = wallet.createWalletTransaction(getUtxoSelectors(), getUtxoFilters(), payments, getFeeRate(), getMinimumFeeRate(), userFee, currentBlockHeight, groupByAddress, includeMempoolOutputs, includeSpentMempoolOutputs); walletTransactionProperty.setValue(walletTransaction); insufficientInputsProperty.set(false); @@ -791,7 +790,7 @@ public class SendController extends WalletFormController implements Initializabl setDefaultFeeRate(); utxoSelectorProperty.setValue(null); utxoFilterProperty.setValue(null); - includeMempoolInputsProperty.set(false); + includeSpentMempoolOutputsProperty.set(false); walletTransactionProperty.setValue(null); createdWalletTransactionProperty.set(null); @@ -957,7 +956,7 @@ public class SendController extends WalletFormController implements Initializabl userFeeSet.set(true); } - includeMempoolInputsProperty.set(event.isIncludeMempoolInputs()); + includeSpentMempoolOutputsProperty.set(event.isIncludeSpentMempoolOutputs()); List utxos = event.getUtxos(); utxoSelectorProperty.set(new PresetUtxoSelector(utxos)); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java index 7478615b..ac31be43 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java @@ -38,7 +38,7 @@ public class WalletTransactionsEntry extends Entry { for(Entry entry : getChildren()) { TransactionEntry transactionEntry = (TransactionEntry)entry; - if(transactionEntry.getConfirmations() != 0 || transactionEntry.getValue() < 0 || Config.get().isIncludeMempoolChange()) { + if(transactionEntry.getConfirmations() != 0 || transactionEntry.getValue() < 0 || Config.get().isIncludeMempoolOutputs()) { balance += entry.getValue(); } diff --git a/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml b/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml index d1819a25..c235a9c4 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml @@ -87,7 +87,7 @@ - +