validate too large fee

This commit is contained in:
Craig Raw 2020-07-05 15:23:33 +02:00
parent 66e558faee
commit 5860a6e49f

View file

@ -80,6 +80,13 @@ public class SendController extends WalletFormController implements Initializabl
private final BooleanProperty insufficientInputsProperty = new SimpleBooleanProperty(false); private final BooleanProperty insufficientInputsProperty = new SimpleBooleanProperty(false);
private final ChangeListener<String> amountListener = new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
updateTransaction();
}
};
private final ChangeListener<String> feeListener = new ChangeListener<>() { private final ChangeListener<String> feeListener = new ChangeListener<>() {
@Override @Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
@ -124,9 +131,7 @@ public class SendController extends WalletFormController implements Initializabl
}); });
amount.setTextFormatter(new TextFieldValidator(TextFieldValidator.ValidationModus.MAX_FRACTION_DIGITS, 8).getFormatter()); amount.setTextFormatter(new TextFieldValidator(TextFieldValidator.ValidationModus.MAX_FRACTION_DIGITS, 8).getFormatter());
amount.textProperty().addListener((observable, oldValue, newValue) -> { amount.textProperty().addListener(amountListener);
updateTransaction();
});
amountUnit.getSelectionModel().select(1); amountUnit.getSelectionModel().select(1);
amountUnit.valueProperty().addListener((observable, oldValue, newValue) -> { amountUnit.valueProperty().addListener((observable, oldValue, newValue) -> {
@ -139,9 +144,16 @@ public class SendController extends WalletFormController implements Initializabl
}); });
insufficientInputsProperty.addListener((observable, oldValue, newValue) -> { insufficientInputsProperty.addListener((observable, oldValue, newValue) -> {
amount.textProperty().removeListener(amountListener);
String amt = amount.getText(); String amt = amount.getText();
amount.setText(amt + " "); amount.setText(amt + "0");
amount.setText(amt); amount.setText(amt);
amount.textProperty().addListener(amountListener);
fee.textProperty().removeListener(feeListener);
String feeAmt = fee.getText();
fee.setText(feeAmt + "0");
fee.setText(feeAmt);
fee.textProperty().addListener(feeListener);
}); });
targetBlocks.setMin(0); targetBlocks.setMin(0);
@ -224,6 +236,7 @@ public class SendController extends WalletFormController implements Initializabl
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Value", getRecipientValueSats() != null && getRecipientValueSats() == 0) (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Value", getRecipientValueSats() != null && getRecipientValueSats() == 0)
)); ));
validationSupport.registerValidator(fee, Validator.combine( validationSupport.registerValidator(fee, Validator.combine(
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Inputs", userFeeSet.get() && insufficientInputsProperty.get()),
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Fee", getFeeValueSats() != null && getFeeValueSats() == 0) (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Fee", getFeeValueSats() != null && getFeeValueSats() == 0)
)); ));