improve variable naming for utxo selection criteria

This commit is contained in:
Craig Raw
2021-04-21 09:37:19 +02:00
parent b836774289
commit 18075e0686
8 changed files with 24 additions and 25 deletions
@@ -11,18 +11,18 @@ public class SpendUtxoEvent {
private final List<BlockTransactionHashIndex> utxos;
private final List<Payment> payments;
private final Long fee;
private final boolean includeMempoolInputs;
private final boolean includeSpentMempoolOutputs;
public SpendUtxoEvent(Wallet wallet, List<BlockTransactionHashIndex> utxos) {
this(wallet, utxos, null, null, false);
}
public SpendUtxoEvent(Wallet wallet, List<BlockTransactionHashIndex> utxos, List<Payment> payments, Long fee, boolean includeMempoolInputs) {
public SpendUtxoEvent(Wallet wallet, List<BlockTransactionHashIndex> utxos, List<Payment> 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;
}
}
@@ -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();
}
@@ -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());
@@ -59,7 +59,7 @@ public class HashIndexEntry extends Entry implements Comparable<HashIndexEntry>
}
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
@@ -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<String> 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<BlockTransactionHashIndex> utxos = event.getUtxos();
utxoSelectorProperty.set(new PresetUtxoSelector(utxos));
@@ -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();
}