From 98b33e184e71f2763d5ca7c6f72a9d99065831fd Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 21 Mar 2023 09:34:19 +0200 Subject: [PATCH] use whirlpool premix priority slider to change mixfeetarget, display warning if chosen fee rate is much lower than normal priority --- .../sparrow/terminal/wallet/MixPoolDialog.java | 1 + .../sparrow/whirlpool/WhirlpoolController.java | 13 ++++++++++++- .../sparrowwallet/sparrow/whirlpool/whirlpool.css | 6 +++++- .../sparrowwallet/sparrow/whirlpool/whirlpool.fxml | 11 +++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/MixPoolDialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/MixPoolDialog.java index 74cb45d7..4cd31961 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/MixPoolDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/MixPoolDialog.java @@ -197,6 +197,7 @@ public class MixPoolDialog extends WalletDialog { tx0Previews = null; whirlpool.setScode(mixConfig.getScode()); whirlpool.setTx0FeeTarget(tx0FeeTarget); + whirlpool.setMixFeeTarget(tx0FeeTarget); Whirlpool.Tx0PreviewsService tx0PreviewsService = new Whirlpool.Tx0PreviewsService(whirlpool, utxoEntries); tx0PreviewsService.setOnRunning(workerStateEvent -> { diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java index 5d2f88bc..30c2bc42 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java @@ -55,6 +55,9 @@ public class WhirlpoolController { @FXML private CopyableLabel premixFeeRate; + @FXML + private Label lowPremixFeeRate; + @FXML private ComboBox pool; @@ -139,9 +142,12 @@ public class WhirlpoolController { tx0Previews = null; tx0PreviewProperty.set(null); Tx0FeeTarget tx0FeeTarget = FEE_TARGETS.get(newValue.intValue()); - premixFeeRate.setText(SparrowMinerFeeSupplier.getFee(Integer.parseInt(tx0FeeTarget.getFeeTarget().getValue())) + " sats/vB"); + premixFeeRate.setText(getFeeRate(tx0FeeTarget) + " sats/vB"); + lowPremixFeeRate.setVisible(tx0FeeTarget == Tx0FeeTarget.MIN && getFeeRate(tx0FeeTarget) * 2 < getFeeRate(Tx0FeeTarget.BLOCKS_4)); }); premixPriority.setValue(1); + lowPremixFeeRate.managedProperty().bind(lowPremixFeeRate.visibleProperty()); + lowPremixFeeRate.setVisible(false); if(mixConfig.getScode() != null) { step1.setVisible(false); @@ -218,6 +224,10 @@ public class WhirlpoolController { }); } + private int getFeeRate(Tx0FeeTarget tx0FeeTarget) { + return SparrowMinerFeeSupplier.getFee(Integer.parseInt(tx0FeeTarget.getFeeTarget().getValue())); + } + public boolean next() { if(step1.isVisible()) { step1.setVisible(false); @@ -318,6 +328,7 @@ public class WhirlpoolController { tx0Previews = null; whirlpool.setScode(mixConfig.getScode()); whirlpool.setTx0FeeTarget(FEE_TARGETS.get(premixPriority.valueProperty().intValue())); + whirlpool.setMixFeeTarget(FEE_TARGETS.get(premixPriority.valueProperty().intValue())); Whirlpool.Tx0PreviewsService tx0PreviewsService = new Whirlpool.Tx0PreviewsService(whirlpool, utxoEntries); tx0PreviewsService.setOnRunning(workerStateEvent -> { diff --git a/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.css b/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.css index 2cfd0f9b..36a4da28 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.css +++ b/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.css @@ -43,4 +43,8 @@ .field-control { -fx-pref-width: 180px; -} \ No newline at end of file +} + +.low-fee-warning { + -fx-text-fill: rgb(238, 210, 2); +} diff --git a/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.fxml b/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.fxml index 510765c1..629bc1ac 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/whirlpool/whirlpool.fxml @@ -107,6 +107,17 @@