From 1d73956853fb98a7cc77f9c6699fd81c60475f2a Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 15 Mar 2021 10:34:18 +0200 Subject: [PATCH] fixes to minimum and pay then replace fee rates --- .../sparrowwallet/sparrow/net/FeeRatesSource.java | 2 ++ .../sparrowwallet/sparrow/wallet/SendController.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java b/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java index d7a323bd..27d80e69 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/FeeRatesSource.java @@ -70,6 +70,8 @@ public enum FeeRatesSource { blockTargetFeeRates.put(blockTarget, threeTierRates.halfHourFee); } else if(blockTarget < BLOCKS_IN_TWO_HOURS || defaultblockTargetFeeRates.get(blockTarget) > threeTierRates.hourFee) { blockTargetFeeRates.put(blockTarget, threeTierRates.hourFee); + } else if(threeTierRates.minimumFee != null && defaultblockTargetFeeRates.get(blockTarget) < threeTierRates.minimumFee) { + blockTargetFeeRates.put(blockTarget, threeTierRates.minimumFee + (threeTierRates.hourFee > threeTierRates.minimumFee ? threeTierRates.hourFee * 0.2 : 0.0)); } else { blockTargetFeeRates.put(blockTarget, defaultblockTargetFeeRates.get(blockTarget)); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 5d9cec4f..5de18e24 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -644,7 +644,7 @@ public class SendController extends WalletFormController implements Initializabl Integer targetBlocks = getTargetBlocks(feeRateAmt); if(targetBlocksFeeRates.get(Integer.MAX_VALUE) != null) { Double minFeeRate = targetBlocksFeeRates.get(Integer.MAX_VALUE); - if(minFeeRate > 1.0 && feeRateAmt <= minFeeRate) { + if(minFeeRate > 1.0 && feeRateAmt < minFeeRate) { feeRatePriority.setText("Below Minimum"); feeRatePriority.setTooltip(new Tooltip("Transactions at this fee rate are currently being purged from the default sized mempool")); feeRatePriorityGlyph.setStyle("-fx-text-fill: #a0a1a7cc"); @@ -653,7 +653,7 @@ public class SendController extends WalletFormController implements Initializabl } Double lowestBlocksRate = targetBlocksFeeRates.get(TARGET_BLOCKS_RANGE.get(TARGET_BLOCKS_RANGE.size() - 1)); - if(lowestBlocksRate > minFeeRate && feeRateAmt < (minFeeRate + ((lowestBlocksRate - minFeeRate) / 2))) { + if(lowestBlocksRate >= minFeeRate && feeRateAmt < (minFeeRate + ((lowestBlocksRate - minFeeRate) / 2)) && !isPayjoinTx()) { feeRatePriority.setText("Try Then Replace"); feeRatePriority.setTooltip(new Tooltip("Send a transaction, verify it appears in the destination wallet, then RBF to get it confirmed or sent to another address")); feeRatePriorityGlyph.setStyle("-fx-text-fill: #7eb7c9cc"); @@ -691,6 +691,14 @@ public class SendController extends WalletFormController implements Initializabl } } + private boolean isPayjoinTx() { + if(walletTransactionProperty.get() != null) { + return walletTransactionProperty.get().getPayments().stream().anyMatch(payment -> AppServices.getPayjoinURI(payment.getAddress()) != null); + } + + return false; + } + private Node getSliderThumb() { return targetBlocks.lookup(".thumb"); }