diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java index ba831a42..d4d81da1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java @@ -79,7 +79,14 @@ public class UtxosController extends WalletFormController implements Initializab }; private final ChangeListener mixingStartingListener = (observable, oldValue, newValue) -> { - startMix.setDisable(newValue); + startMix.setDisable(newValue || !AppServices.onlineProperty().get()); + Platform.runLater(() -> startMix.setText(newValue && AppServices.onlineProperty().get() ? "Starting Mixing..." : "Start Mixing")); + mixTo.setDisable(newValue); + }; + + private final ChangeListener mixingStoppingListener = (observable, oldValue, newValue) -> { + startMix.setDisable(newValue || !AppServices.onlineProperty().get()); + Platform.runLater(() -> startMix.setText(newValue ? "Stopping Mixing..." : "Start Mixing")); mixTo.setDisable(newValue); }; @@ -101,7 +108,6 @@ public class UtxosController extends WalletFormController implements Initializab startMix.visibleProperty().bind(stopMix.visibleProperty().not()); stopMix.visibleProperty().addListener((observable, oldValue, newValue) -> { stopMix.setDisable(!newValue); - startMix.setDisable(newValue || !AppServices.onlineProperty().get()); }); mixTo.managedProperty().bind(mixTo.visibleProperty()); mixTo.setVisible(getWalletForm().getWallet().getStandardAccountType() == StandardAccount.WHIRLPOOL_POSTMIX); @@ -111,6 +117,7 @@ public class UtxosController extends WalletFormController implements Initializab if(whirlpool != null) { stopMix.visibleProperty().bind(whirlpool.mixingProperty()); whirlpool.startingProperty().addListener(new WeakChangeListener<>(mixingStartingListener)); + whirlpool.stoppingProperty().addListener(new WeakChangeListener<>(mixingStoppingListener)); updateMixToButton(); } } @@ -322,7 +329,7 @@ public class UtxosController extends WalletFormController implements Initializab public void stopMixing(ActionEvent event) { stopMix.setDisable(true); - startMix.setDisable(false); + startMix.setDisable(!AppServices.onlineProperty().get()); getWalletForm().getWallet().getMasterMixConfig().setMixOnStartup(Boolean.FALSE); EventManager.get().post(new WalletMasterMixConfigChangedEvent(getWalletForm().getWallet())); diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index ae267b9e..2d0134d5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -76,6 +76,7 @@ public class Whirlpool { private String mixToWalletId; private final BooleanProperty startingProperty = new SimpleBooleanProperty(false); + private final BooleanProperty stoppingProperty = new SimpleBooleanProperty(false); private final BooleanProperty mixingProperty = new SimpleBooleanProperty(false); public Whirlpool(Network network, HostAndPort torProxy) { @@ -408,6 +409,14 @@ public class Whirlpool { return startingProperty; } + public boolean isStopping() { + return stoppingProperty.get(); + } + + public BooleanProperty stoppingProperty() { + return stoppingProperty; + } + @Subscribe public void onMixSuccess(MixSuccessEvent e) { WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); @@ -547,8 +556,8 @@ public class Whirlpool { WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet(); if(AppServices.onlineProperty().get()) { whirlpoolWallet.start(); - whirlpool.startingProperty.set(false); } + whirlpool.startingProperty.set(false); return whirlpoolWallet; } @@ -569,8 +578,9 @@ public class Whirlpool { protected Boolean call() throws Exception { updateProgress(-1, 1); updateMessage("Disconnecting from Whirlpool..."); - + whirlpool.stoppingProperty.set(true); whirlpool.shutdown(); + whirlpool.stoppingProperty.set(false); return true; } }; @@ -590,15 +600,17 @@ public class Whirlpool { protected Boolean call() throws Exception { updateProgress(-1, 1); updateMessage("Disconnecting from Whirlpool..."); + whirlpool.stoppingProperty.set(true); whirlpool.shutdown(); + whirlpool.stoppingProperty.set(false); updateMessage("Starting Whirlpool..."); whirlpool.startingProperty.set(true); WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet(); if(AppServices.onlineProperty().get()) { whirlpoolWallet.start(); - whirlpool.startingProperty.set(false); } + whirlpool.startingProperty.set(false); return true; }