diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index a1456526..6417c8fa 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -319,7 +319,8 @@ public class Whirlpool { if(!whirlpoolWalletService.whirlpoolWallet().isStarted()) { log.warn("Wallet is not started, but mixingProperty is true"); WhirlpoolEventService.getInstance().post(new WalletStopEvent(whirlpoolWalletService.whirlpoolWallet())); - } else if(whirlpoolWalletService.whirlpoolWallet().getMixingState().getUtxosMixing().isEmpty()) { + } else if(whirlpoolWalletService.whirlpoolWallet().getMixingState().getUtxosMixing().isEmpty() && + !whirlpoolWalletService.whirlpoolWallet().getUtxoSupplier().findUtxos(WhirlpoolAccount.PREMIX, WhirlpoolAccount.POSTMIX).isEmpty()) { log.warn("No UTXOs mixing, but mixingProperty is true"); //Will automatically restart AppServices.getWhirlpoolServices().stopWhirlpool(this, false); diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/dataSource/SparrowDataSource.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/dataSource/SparrowDataSource.java index f98cacd2..0a941f5a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/dataSource/SparrowDataSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/dataSource/SparrowDataSource.java @@ -33,6 +33,7 @@ import com.sparrowwallet.sparrow.event.WalletAddressesChangedEvent; import com.sparrowwallet.sparrow.event.WalletHistoryChangedEvent; import com.sparrowwallet.sparrow.net.ElectrumServer; import com.sparrowwallet.sparrow.whirlpool.Whirlpool; +import javafx.application.Platform; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -246,12 +247,12 @@ public class SparrowDataSource extends WalletResponseDataSource { @Subscribe public void walletHistoryChanged(WalletHistoryChangedEvent event) { - refreshWallet(event.getWalletId()); + refreshWallet(event.getWalletId(), event.getWallet()); } @Subscribe public void walletAddressesChanged(WalletAddressesChangedEvent event) { - refreshWallet(event.getWalletId()); + refreshWallet(event.getWalletId(), event.getWallet()); } @Subscribe @@ -263,14 +264,19 @@ public class SparrowDataSource extends WalletResponseDataSource { } } - private void refreshWallet(String eventWalletId) { + private void refreshWallet(String walletId, Wallet wallet) { try { // match :master, :Premix, :Postmix - if (eventWalletId.startsWith(walletIdentifierPrefix)) { - refresh(); + if(walletId.startsWith(walletIdentifierPrefix) && (wallet.isWhirlpoolMasterWallet() || wallet.isWhirlpoolChildWallet())) { + Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(wallet); + if(whirlpool != null && whirlpool.isStarting()) { + Platform.runLater(() -> refreshWallet(walletId, wallet)); + } else { + refresh(); + } } } catch (Exception e) { - log.error("", e); + log.error("Error refreshing wallet", e); } } }