diff --git a/drongo b/drongo index 79eb8b00..b2297a8d 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 79eb8b002d01be5195bb7fc7eba6bb34bf3366e3 +Subproject commit b2297a8d0219af70b3e97c83feb1af8aec485d9f diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index c1b11d0d..339c0937 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -172,7 +172,7 @@ public class SendController extends WalletFormController implements Initializabl }); label.textProperty().addListener((observable, oldValue, newValue) -> { - createButton.setDisable(walletTransactionProperty.get() == null || newValue == null || newValue.isEmpty()); + createButton.setDisable(walletTransactionProperty.get() == null || newValue == null || newValue.isEmpty() || isInsufficientFeeRate()); }); amount.setTextFormatter(new CoinTextFormatter()); @@ -275,7 +275,7 @@ public class SendController extends WalletFormController implements Initializabl setFiatAmount(AppController.getFiatCurrencyExchangeRate(), walletTransaction.getRecipientAmount()); } - double feeRate = (double)walletTransaction.getFee() / walletTransaction.getTransaction().getVirtualSize(); + double feeRate = walletTransaction.getFeeRate(); if(userFeeSet.get()) { setTargetBlocks(getTargetBlocks(feeRate)); } else { @@ -286,7 +286,7 @@ public class SendController extends WalletFormController implements Initializabl } transactionDiagram.update(walletTransaction); - createButton.setDisable(walletTransaction == null || label.getText().isEmpty()); + createButton.setDisable(walletTransaction == null || label.getText().isEmpty() || isInsufficientFeeRate()); }); addValidation(); @@ -307,8 +307,7 @@ public class SendController extends WalletFormController implements Initializabl 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 Rate", walletTransactionProperty.get() != null && - (double)walletTransactionProperty.get().getFee() / walletTransactionProperty.get().getTransaction().getVirtualSize() < AppController.getMinimumRelayFeeRate()) + (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Fee Rate", isInsufficientFeeRate()) )); validationSupport.setValidationDecorator(new StyleClassValidationDecoration()); @@ -460,6 +459,10 @@ public class SendController extends WalletFormController implements Initializabl return Math.max(minRate, Transaction.DUST_RELAY_TX_FEE); } + private boolean isInsufficientFeeRate() { + return walletTransactionProperty.get() != null && walletTransactionProperty.get().getFeeRate() < AppController.getMinimumRelayFeeRate(); + } + private void setFeeRate(Double feeRateAmt) { feeRate.setText(String.format("%.2f", feeRateAmt) + " sats/vByte"); }