From c86273b0cbeb1668f8e0da8c52fda763e3cc5106 Mon Sep 17 00:00:00 2001 From: Thauan Amorim Date: Tue, 15 Jul 2025 20:56:00 -0300 Subject: [PATCH] Fix: Create button is now disabled if the rate is invalid --- .../sparrowwallet/sparrow/wallet/SendController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 71bbb97b..7c2e2626 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -178,6 +178,7 @@ public class SendController extends WalletFormController implements Initializabl setFiatFeeAmount(AppServices.getFiatCurrencyExchangeRate(), getFeeValueSats()); } + createButton.setDisable(isInsufficientFeeRate()); setTargetBlocks(getTargetBlocks()); updateTransaction(); } @@ -456,8 +457,8 @@ public class SendController extends WalletFormController implements Initializabl validationSupport.setValidationDecorator(new StyleClassValidationDecoration()); 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.fromWarningIf( c, "Insufficient Fee Rate", isInsufficientFeeRate()) + (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Fee", isInsufficientFeeRate()), + (Control c, String newValue) -> ValidationResult.fromWarningIf( c, "Fee Rate Below Minimum", isBelowMinimumFeeRate()) )); validationSupport.setErrorDecorationEnabled(false); @@ -862,10 +863,14 @@ public class SendController extends WalletFormController implements Initializabl return AppServices.getMempoolHistogram(); } - public boolean isInsufficientFeeRate() { + public boolean isBelowMinimumFeeRate() { return walletTransactionProperty.get() != null && walletTransactionProperty.get().getFeeRate() < AppServices.getMinimumRelayFeeRate(); } + public boolean isInsufficientFeeRate() { + return getFeeValueSats() == null || getFeeValueSats() == 0; + } + private void setFeeRate(Double feeRateAmt) { UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat(); feeRate.setText(format.getCurrencyFormat().format(feeRateAmt) + (cpfpFeeRate.isVisible() ? "" : " sats/vB"));