Fix: Create button is now disabled if the rate is invalid

This commit is contained in:
Thauan Amorim 2025-07-15 20:56:00 -03:00
parent c5076de9a5
commit c86273b0cb

View file

@ -178,6 +178,7 @@ public class SendController extends WalletFormController implements Initializabl
setFiatFeeAmount(AppServices.getFiatCurrencyExchangeRate(), getFeeValueSats()); setFiatFeeAmount(AppServices.getFiatCurrencyExchangeRate(), getFeeValueSats());
} }
createButton.setDisable(isInsufficientFeeRate());
setTargetBlocks(getTargetBlocks()); setTargetBlocks(getTargetBlocks());
updateTransaction(); updateTransaction();
} }
@ -456,8 +457,8 @@ public class SendController extends WalletFormController implements Initializabl
validationSupport.setValidationDecorator(new StyleClassValidationDecoration()); validationSupport.setValidationDecorator(new StyleClassValidationDecoration());
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 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", isInsufficientFeeRate()),
(Control c, String newValue) -> ValidationResult.fromWarningIf( c, "Insufficient Fee Rate", isInsufficientFeeRate()) (Control c, String newValue) -> ValidationResult.fromWarningIf( c, "Fee Rate Below Minimum", isBelowMinimumFeeRate())
)); ));
validationSupport.setErrorDecorationEnabled(false); validationSupport.setErrorDecorationEnabled(false);
@ -862,10 +863,14 @@ public class SendController extends WalletFormController implements Initializabl
return AppServices.getMempoolHistogram(); return AppServices.getMempoolHistogram();
} }
public boolean isInsufficientFeeRate() { public boolean isBelowMinimumFeeRate() {
return walletTransactionProperty.get() != null && walletTransactionProperty.get().getFeeRate() < AppServices.getMinimumRelayFeeRate(); return walletTransactionProperty.get() != null && walletTransactionProperty.get().getFeeRate() < AppServices.getMinimumRelayFeeRate();
} }
public boolean isInsufficientFeeRate() {
return getFeeValueSats() == null || getFeeValueSats() == 0;
}
private void setFeeRate(Double feeRateAmt) { private void setFeeRate(Double feeRateAmt) {
UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat(); UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat();
feeRate.setText(format.getCurrencyFormat().format(feeRateAmt) + (cpfpFeeRate.isVisible() ? "" : " sats/vB")); feeRate.setText(format.getCurrencyFormat().format(feeRateAmt) + (cpfpFeeRate.isVisible() ? "" : " sats/vB"));