diff --git a/drongo b/drongo index 38783d68..c9e57fad 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 38783d68a49ecf5d8c8640edb299d693f455b2a9 +Subproject commit c9e57fad018750a150a563cd17c8872d7cda48f0 diff --git a/src/main/java/com/sparrowwallet/sparrow/control/TorStatusLabel.java b/src/main/java/com/sparrowwallet/sparrow/control/TorStatusLabel.java index f4eb5a54..81549b03 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/TorStatusLabel.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/TorStatusLabel.java @@ -43,6 +43,7 @@ public class TorStatusLabel extends Label { } } else if(!torConnectionTest.isRunning()) { torConnectionTest.setPeriod(Duration.seconds(20.0)); + torConnectionTest.setBackoffStrategy(null); torConnectionTest.setOnSucceeded(workerStateEvent -> { getStyleClass().remove("failure"); setTooltip(new Tooltip("External Tor proxy enabled")); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java index dfd1e264..ba831a42 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java @@ -133,7 +133,7 @@ public class UtxosController extends WalletFormController implements Initializab } private boolean canWalletMix() { - return Network.get() == Network.TESTNET && getWalletForm().getWallet().getKeystores().size() == 1 && getWalletForm().getWallet().getKeystores().get(0).hasSeed() && !getWalletForm().getWallet().isWhirlpoolMixWallet(); + return getWalletForm().getWallet().getKeystores().size() == 1 && getWalletForm().getWallet().getKeystores().get(0).hasSeed() && !getWalletForm().getWallet().isWhirlpoolMixWallet(); } private void updateButtons(BitcoinUnit unit) { diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index c16e463a..ae267b9e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -107,9 +107,13 @@ public class Whirlpool { return whirlpoolWalletConfig; } - public Collection getPools() throws Exception { + public Collection getPools(Long totalUtxoValue) throws Exception { this.poolSupplier.load(); - return poolSupplier.getPools(); + if(totalUtxoValue == null) { + return poolSupplier.getPools(); + } + + return tx0ParamService.findPools(poolSupplier.getPools(), totalUtxoValue); } public Tx0Previews getTx0Previews(Collection utxos) throws Exception { @@ -458,16 +462,18 @@ public class Whirlpool { public static class PoolsService extends Service> { private final Whirlpool whirlpool; + private final Long totalUtxoValue; - public PoolsService(Whirlpool whirlpool) { + public PoolsService(Whirlpool whirlpool, Long totalUtxoValue) { this.whirlpool = whirlpool; + this.totalUtxoValue = totalUtxoValue; } @Override protected Task> createTask() { return new Task<>() { protected Collection call() throws Exception { - return whirlpool.getPools(); + return whirlpool.getPools(totalUtxoValue); } }; } diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java index c1ef0c79..8181d9ee 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java @@ -217,17 +217,22 @@ public class WhirlpoolController { private void fetchPools() { long totalUtxoValue = utxoEntries.stream().mapToLong(Entry::getValue).sum(); - Whirlpool.PoolsService poolsService = new Whirlpool.PoolsService(AppServices.getWhirlpoolServices().getWhirlpool(walletId)); + Whirlpool.PoolsService poolsService = new Whirlpool.PoolsService(AppServices.getWhirlpoolServices().getWhirlpool(walletId), totalUtxoValue); poolsService.setOnSucceeded(workerStateEvent -> { - List availablePools = poolsService.getValue().stream().filter(pool1 -> totalUtxoValue >= (pool1.getPremixValueMin() + pool1.getFeeValue())).toList(); + List availablePools = poolsService.getValue().stream().toList(); if(availablePools.isEmpty()) { pool.setVisible(false); - OptionalLong optMinValue = poolsService.getValue().stream().mapToLong(pool1 -> pool1.getPremixValueMin() + pool1.getFeeValue()).min(); - if(optMinValue.isPresent()) { - String satsValue = String.format(Locale.ENGLISH, "%,d", optMinValue.getAsLong()) + " sats"; - String btcValue = CoinLabel.BTC_FORMAT.format((double)optMinValue.getAsLong() / Transaction.SATOSHIS_PER_BITCOIN) + " BTC"; - poolInsufficient.setText("No available pools. Select a value over " + (Config.get().getBitcoinUnit() == BitcoinUnit.BTC ? btcValue : satsValue) + "."); - } + + Whirlpool.PoolsService allPoolsService = new Whirlpool.PoolsService(AppServices.getWhirlpoolServices().getWhirlpool(walletId), null); + allPoolsService.setOnSucceeded(poolsStateEvent -> { + OptionalLong optMinValue = allPoolsService.getValue().stream().mapToLong(pool1 -> pool1.getPremixValueMin() + pool1.getFeeValue()).min(); + if(optMinValue.isPresent() && totalUtxoValue < optMinValue.getAsLong()) { + String satsValue = String.format(Locale.ENGLISH, "%,d", optMinValue.getAsLong()) + " sats"; + String btcValue = CoinLabel.BTC_FORMAT.format((double)optMinValue.getAsLong() / Transaction.SATOSHIS_PER_BITCOIN) + " BTC"; + poolInsufficient.setText("No available pools. Select a value over " + (Config.get().getBitcoinUnit() == BitcoinUnit.BTC ? btcValue : satsValue) + "."); + } + }); + allPoolsService.start(); } else { pool.setDisable(false); pool.setItems(FXCollections.observableList(availablePools)); @@ -285,7 +290,7 @@ public class WhirlpoolController { exception = exception.getCause(); } - nbOutputsLoading.setText("Error fetching fee: " + exception.getMessage()); + nbOutputsLoading.setText("Error fetching Tx0: " + exception.getMessage()); }); tx0PreviewsService.start(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java index d5c372a6..24d01d9a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolServices.java @@ -43,6 +43,11 @@ public class WhirlpoolServices { HostAndPort torProxy = getTorProxy(); whirlpool = new Whirlpool(Network.get(), torProxy); whirlpoolMap.put(walletId, whirlpool); + } else if(!whirlpool.isStarted()) { + HostAndPort torProxy = getTorProxy(); + if(!Objects.equals(whirlpool.getTorProxy(), torProxy)) { + whirlpool.setTorProxy(getTorProxy()); + } } return whirlpool;