mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-23 20:36:44 +00:00
increase maximum gap limit, but display warning when gap limit is over 999
This commit is contained in:
parent
2b4d3fac6c
commit
d3d939889e
3 changed files with 36 additions and 3 deletions
|
@ -11,6 +11,7 @@ import javafx.fxml.FXML;
|
|||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.DatePicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -23,12 +24,18 @@ import java.util.stream.Collectors;
|
|||
public class AdvancedController implements Initializable {
|
||||
private static final List<Integer> DEFAULT_WATCH_LIST_ITEMS = List.of(-1, 100, 500, 1000, 5000, 10000);
|
||||
|
||||
private static final int MAX_GAP_LIMIT = 1000000;
|
||||
private static final int WARNING_GAP_LIMIT = 1000;
|
||||
|
||||
@FXML
|
||||
private DatePicker birthDate;
|
||||
|
||||
@FXML
|
||||
private IntegerSpinner gapLimit;
|
||||
|
||||
@FXML
|
||||
private Label gapWarning;
|
||||
|
||||
@FXML
|
||||
private ComboBox<Integer> watchLast;
|
||||
|
||||
|
@ -49,12 +56,14 @@ public class AdvancedController implements Initializable {
|
|||
}
|
||||
});
|
||||
|
||||
gapLimit.setValueFactory(new IntegerSpinner.ValueFactory(Wallet.DEFAULT_LOOKAHEAD, 9999, wallet.getGapLimit()));
|
||||
gapLimit.setValueFactory(new IntegerSpinner.ValueFactory(Wallet.DEFAULT_LOOKAHEAD, MAX_GAP_LIMIT, wallet.getGapLimit()));
|
||||
gapLimit.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if(newValue == null || newValue < Wallet.DEFAULT_LOOKAHEAD || newValue > 9999) {
|
||||
if(newValue == null || newValue < Wallet.DEFAULT_LOOKAHEAD || newValue > MAX_GAP_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
gapWarning.setVisible(newValue >= WARNING_GAP_LIMIT);
|
||||
|
||||
wallet.setGapLimit(newValue);
|
||||
if(!watchLast.getItems().equals(getWatchListItems(wallet))) {
|
||||
Integer value = watchLast.getValue();
|
||||
|
@ -63,6 +72,17 @@ public class AdvancedController implements Initializable {
|
|||
}
|
||||
EventManager.get().post(new SettingsChangedEvent(wallet, SettingsChangedEvent.Type.GAP_LIMIT));
|
||||
});
|
||||
gapLimit.getEditor().textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
try {
|
||||
int gapLimit = Integer.parseInt(newValue);
|
||||
gapWarning.setVisible(gapLimit >= WARNING_GAP_LIMIT);
|
||||
} catch(Exception e) {
|
||||
//ignore
|
||||
}
|
||||
});
|
||||
|
||||
gapWarning.managedProperty().bind(gapWarning.visibleProperty());
|
||||
gapWarning.setVisible(wallet.getGapLimit() >= WARNING_GAP_LIMIT);
|
||||
|
||||
watchLast.setItems(getWatchListItems(wallet));
|
||||
watchLast.setConverter(new StringConverter<>() {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
.gap-warning {
|
||||
-fx-text-fill: rgb(238, 210, 2);
|
||||
-fx-padding: 0 0 0 12;
|
||||
}
|
|
@ -11,8 +11,9 @@
|
|||
<?import com.sparrowwallet.sparrow.control.HelpLabel?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import com.sparrowwallet.sparrow.control.IntegerSpinner?>
|
||||
<?import org.controlsfx.glyphfont.Glyph?>
|
||||
|
||||
<BorderPane stylesheets="@../general.css" styleClass="line-border" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.wallet.AdvancedController">
|
||||
<BorderPane stylesheets="@advanced.css, @../general.css" styleClass="line-border" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.wallet.AdvancedController">
|
||||
<center>
|
||||
<GridPane hgap="10.0" vgap="10.0">
|
||||
<padding>
|
||||
|
@ -34,6 +35,14 @@
|
|||
<Field text="Gap limit:">
|
||||
<IntegerSpinner fx:id="gapLimit" editable="true" prefWidth="90" />
|
||||
<HelpLabel helpText="Change how far ahead to look for additional transactions beyond the highest derivation with previous transaction outputs."/>
|
||||
<Label fx:id="gapWarning">
|
||||
<graphic>
|
||||
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="12" icon="EXCLAMATION_TRIANGLE" styleClass="gap-warning" />
|
||||
</graphic>
|
||||
<tooltip>
|
||||
<Tooltip text="Large gap limits may cause wallet loading failures on some servers." />
|
||||
</tooltip>
|
||||
</Label>
|
||||
</Field>
|
||||
<Field text="Watch addresses:">
|
||||
<ComboBox fx:id="watchLast" />
|
||||
|
|
Loading…
Reference in a new issue