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

2
drongo

@ -1 +1 @@
Subproject commit a25dfa5c7671023b60d1773cf603b4d46885a546 Subproject commit efaa6a066d2b7d7f982086060aa8f014ca89a190

View file

@ -11,18 +11,18 @@ public class SpendUtxoEvent {
private final List<BlockTransactionHashIndex> utxos; private final List<BlockTransactionHashIndex> utxos;
private final List<Payment> payments; private final List<Payment> payments;
private final Long fee; private final Long fee;
private final boolean includeMempoolInputs; private final boolean includeSpentMempoolOutputs;
public SpendUtxoEvent(Wallet wallet, List<BlockTransactionHashIndex> utxos) { public SpendUtxoEvent(Wallet wallet, List<BlockTransactionHashIndex> utxos) {
this(wallet, utxos, null, null, false); 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.wallet = wallet;
this.utxos = utxos; this.utxos = utxos;
this.payments = payments; this.payments = payments;
this.fee = fee; this.fee = fee;
this.includeMempoolInputs = includeMempoolInputs; this.includeSpentMempoolOutputs = includeSpentMempoolOutputs;
} }
public Wallet getWallet() { public Wallet getWallet() {
@ -41,7 +41,7 @@ public class SpendUtxoEvent {
return fee; return fee;
} }
public boolean isIncludeMempoolInputs() { public boolean isIncludeSpentMempoolOutputs() {
return includeMempoolInputs; return includeSpentMempoolOutputs;
} }
} }

View file

@ -28,7 +28,7 @@ public class Config {
private boolean loadRecentWallets = true; private boolean loadRecentWallets = true;
private boolean validateDerivationPaths = true; private boolean validateDerivationPaths = true;
private boolean groupByAddress = true; private boolean groupByAddress = true;
private boolean includeMempoolChange = true; private boolean includeMempoolOutputs = true;
private boolean notifyNewTransactions = true; private boolean notifyNewTransactions = true;
private boolean checkNewVersions = true; private boolean checkNewVersions = true;
private Theme theme; private Theme theme;
@ -183,12 +183,12 @@ public class Config {
flush(); flush();
} }
public boolean isIncludeMempoolChange() { public boolean isIncludeMempoolOutputs() {
return includeMempoolChange; return includeMempoolOutputs;
} }
public void setIncludeMempoolChange(boolean includeMempoolChange) { public void setIncludeMempoolOutputs(boolean includeMempoolOutputs) {
this.includeMempoolChange = includeMempoolChange; this.includeMempoolOutputs = includeMempoolOutputs;
flush(); flush();
} }

View file

@ -43,7 +43,7 @@ public class GeneralPreferencesController extends PreferencesDetailController {
private UnlabeledToggleSwitch groupByAddress; private UnlabeledToggleSwitch groupByAddress;
@FXML @FXML
private UnlabeledToggleSwitch includeMempoolChange; private UnlabeledToggleSwitch includeMempoolOutputs;
@FXML @FXML
private UnlabeledToggleSwitch notifyNewTransactions; private UnlabeledToggleSwitch notifyNewTransactions;
@ -113,12 +113,12 @@ public class GeneralPreferencesController extends PreferencesDetailController {
}); });
groupByAddress.setSelected(config.isGroupByAddress()); groupByAddress.setSelected(config.isGroupByAddress());
includeMempoolChange.setSelected(config.isIncludeMempoolChange()); includeMempoolOutputs.setSelected(config.isIncludeMempoolOutputs());
groupByAddress.selectedProperty().addListener((observableValue, oldValue, newValue) -> { groupByAddress.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
config.setGroupByAddress(newValue); config.setGroupByAddress(newValue);
}); });
includeMempoolChange.selectedProperty().addListener((observableValue, oldValue, newValue) -> { includeMempoolOutputs.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
config.setIncludeMempoolChange(newValue); config.setIncludeMempoolOutputs(newValue);
}); });
notifyNewTransactions.setSelected(config.isNotifyNewTransactions()); notifyNewTransactions.setSelected(config.isNotifyNewTransactions());

View file

@ -59,7 +59,7 @@ public class HashIndexEntry extends Entry implements Comparable<HashIndexEntry>
} }
public boolean isSpendable() { 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 @Override

View file

@ -44,7 +44,6 @@ import java.net.URL;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class SendController extends WalletFormController implements Initializable { 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 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<>() { private final ChangeListener<String> feeListener = new ChangeListener<>() {
@Override @Override
@ -480,9 +479,9 @@ public class SendController extends WalletFormController implements Initializabl
Long userFee = userFeeSet.get() ? getFeeValueSats() : null; Long userFee = userFeeSet.get() ? getFeeValueSats() : null;
Integer currentBlockHeight = AppServices.getCurrentBlockHeight(); Integer currentBlockHeight = AppServices.getCurrentBlockHeight();
boolean groupByAddress = Config.get().isGroupByAddress(); boolean groupByAddress = Config.get().isGroupByAddress();
boolean includeMempoolChange = Config.get().isIncludeMempoolChange(); boolean includeMempoolOutputs = Config.get().isIncludeMempoolOutputs();
boolean includeMempoolInputs = includeMempoolInputsProperty.get(); boolean includeSpentMempoolOutputs = includeSpentMempoolOutputsProperty.get();
WalletTransaction walletTransaction = wallet.createWalletTransaction(getUtxoSelectors(), getUtxoFilters(), payments, getFeeRate(), getMinimumFeeRate(), userFee, currentBlockHeight, groupByAddress, includeMempoolChange, includeMempoolInputs); WalletTransaction walletTransaction = wallet.createWalletTransaction(getUtxoSelectors(), getUtxoFilters(), payments, getFeeRate(), getMinimumFeeRate(), userFee, currentBlockHeight, groupByAddress, includeMempoolOutputs, includeSpentMempoolOutputs);
walletTransactionProperty.setValue(walletTransaction); walletTransactionProperty.setValue(walletTransaction);
insufficientInputsProperty.set(false); insufficientInputsProperty.set(false);
@ -791,7 +790,7 @@ public class SendController extends WalletFormController implements Initializabl
setDefaultFeeRate(); setDefaultFeeRate();
utxoSelectorProperty.setValue(null); utxoSelectorProperty.setValue(null);
utxoFilterProperty.setValue(null); utxoFilterProperty.setValue(null);
includeMempoolInputsProperty.set(false); includeSpentMempoolOutputsProperty.set(false);
walletTransactionProperty.setValue(null); walletTransactionProperty.setValue(null);
createdWalletTransactionProperty.set(null); createdWalletTransactionProperty.set(null);
@ -957,7 +956,7 @@ public class SendController extends WalletFormController implements Initializabl
userFeeSet.set(true); userFeeSet.set(true);
} }
includeMempoolInputsProperty.set(event.isIncludeMempoolInputs()); includeSpentMempoolOutputsProperty.set(event.isIncludeSpentMempoolOutputs());
List<BlockTransactionHashIndex> utxos = event.getUtxos(); List<BlockTransactionHashIndex> utxos = event.getUtxos();
utxoSelectorProperty.set(new PresetUtxoSelector(utxos)); utxoSelectorProperty.set(new PresetUtxoSelector(utxos));

View file

@ -38,7 +38,7 @@ public class WalletTransactionsEntry extends Entry {
for(Entry entry : getChildren()) { for(Entry entry : getChildren()) {
TransactionEntry transactionEntry = (TransactionEntry)entry; 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(); balance += entry.getValue();
} }

View file

@ -87,7 +87,7 @@
<HelpLabel helpText="Group UTXOs by address when sending to improve privacy by only sending from an address once."/> <HelpLabel helpText="Group UTXOs by address when sending to improve privacy by only sending from an address once."/>
</Field> </Field>
<Field text="Allow unconfirmed:"> <Field text="Allow unconfirmed:">
<UnlabeledToggleSwitch fx:id="includeMempoolChange" /> <UnlabeledToggleSwitch fx:id="includeMempoolOutputs" />
<HelpLabel helpText="Allow a wallet to spend UTXOs that are still in the mempool."/> <HelpLabel helpText="Allow a wallet to spend UTXOs that are still in the mempool."/>
</Field> </Field>
</Fieldset> </Fieldset>