mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-01-29 03:31:11 +00:00
mainnet mixing, improve pools selection, other fixes
This commit is contained in:
parent
c55b19af0f
commit
427a6925ee
6 changed files with 32 additions and 15 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 38783d68a49ecf5d8c8640edb299d693f455b2a9
|
Subproject commit c9e57fad018750a150a563cd17c8872d7cda48f0
|
|
@ -43,6 +43,7 @@ public class TorStatusLabel extends Label {
|
||||||
}
|
}
|
||||||
} else if(!torConnectionTest.isRunning()) {
|
} else if(!torConnectionTest.isRunning()) {
|
||||||
torConnectionTest.setPeriod(Duration.seconds(20.0));
|
torConnectionTest.setPeriod(Duration.seconds(20.0));
|
||||||
|
torConnectionTest.setBackoffStrategy(null);
|
||||||
torConnectionTest.setOnSucceeded(workerStateEvent -> {
|
torConnectionTest.setOnSucceeded(workerStateEvent -> {
|
||||||
getStyleClass().remove("failure");
|
getStyleClass().remove("failure");
|
||||||
setTooltip(new Tooltip("External Tor proxy enabled"));
|
setTooltip(new Tooltip("External Tor proxy enabled"));
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class UtxosController extends WalletFormController implements Initializab
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canWalletMix() {
|
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) {
|
private void updateButtons(BitcoinUnit unit) {
|
||||||
|
|
|
@ -107,9 +107,13 @@ public class Whirlpool {
|
||||||
return whirlpoolWalletConfig;
|
return whirlpoolWalletConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Pool> getPools() throws Exception {
|
public Collection<Pool> getPools(Long totalUtxoValue) throws Exception {
|
||||||
this.poolSupplier.load();
|
this.poolSupplier.load();
|
||||||
return poolSupplier.getPools();
|
if(totalUtxoValue == null) {
|
||||||
|
return poolSupplier.getPools();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tx0ParamService.findPools(poolSupplier.getPools(), totalUtxoValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tx0Previews getTx0Previews(Collection<UnspentOutput> utxos) throws Exception {
|
public Tx0Previews getTx0Previews(Collection<UnspentOutput> utxos) throws Exception {
|
||||||
|
@ -458,16 +462,18 @@ public class Whirlpool {
|
||||||
|
|
||||||
public static class PoolsService extends Service<Collection<Pool>> {
|
public static class PoolsService extends Service<Collection<Pool>> {
|
||||||
private final Whirlpool whirlpool;
|
private final Whirlpool whirlpool;
|
||||||
|
private final Long totalUtxoValue;
|
||||||
|
|
||||||
public PoolsService(Whirlpool whirlpool) {
|
public PoolsService(Whirlpool whirlpool, Long totalUtxoValue) {
|
||||||
this.whirlpool = whirlpool;
|
this.whirlpool = whirlpool;
|
||||||
|
this.totalUtxoValue = totalUtxoValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Task<Collection<Pool>> createTask() {
|
protected Task<Collection<Pool>> createTask() {
|
||||||
return new Task<>() {
|
return new Task<>() {
|
||||||
protected Collection<Pool> call() throws Exception {
|
protected Collection<Pool> call() throws Exception {
|
||||||
return whirlpool.getPools();
|
return whirlpool.getPools(totalUtxoValue);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,17 +217,22 @@ public class WhirlpoolController {
|
||||||
|
|
||||||
private void fetchPools() {
|
private void fetchPools() {
|
||||||
long totalUtxoValue = utxoEntries.stream().mapToLong(Entry::getValue).sum();
|
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 -> {
|
poolsService.setOnSucceeded(workerStateEvent -> {
|
||||||
List<Pool> availablePools = poolsService.getValue().stream().filter(pool1 -> totalUtxoValue >= (pool1.getPremixValueMin() + pool1.getFeeValue())).toList();
|
List<Pool> availablePools = poolsService.getValue().stream().toList();
|
||||||
if(availablePools.isEmpty()) {
|
if(availablePools.isEmpty()) {
|
||||||
pool.setVisible(false);
|
pool.setVisible(false);
|
||||||
OptionalLong optMinValue = poolsService.getValue().stream().mapToLong(pool1 -> pool1.getPremixValueMin() + pool1.getFeeValue()).min();
|
|
||||||
if(optMinValue.isPresent()) {
|
Whirlpool.PoolsService allPoolsService = new Whirlpool.PoolsService(AppServices.getWhirlpoolServices().getWhirlpool(walletId), null);
|
||||||
String satsValue = String.format(Locale.ENGLISH, "%,d", optMinValue.getAsLong()) + " sats";
|
allPoolsService.setOnSucceeded(poolsStateEvent -> {
|
||||||
String btcValue = CoinLabel.BTC_FORMAT.format((double)optMinValue.getAsLong() / Transaction.SATOSHIS_PER_BITCOIN) + " BTC";
|
OptionalLong optMinValue = allPoolsService.getValue().stream().mapToLong(pool1 -> pool1.getPremixValueMin() + pool1.getFeeValue()).min();
|
||||||
poolInsufficient.setText("No available pools. Select a value over " + (Config.get().getBitcoinUnit() == BitcoinUnit.BTC ? btcValue : satsValue) + ".");
|
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 {
|
} else {
|
||||||
pool.setDisable(false);
|
pool.setDisable(false);
|
||||||
pool.setItems(FXCollections.observableList(availablePools));
|
pool.setItems(FXCollections.observableList(availablePools));
|
||||||
|
@ -285,7 +290,7 @@ public class WhirlpoolController {
|
||||||
exception = exception.getCause();
|
exception = exception.getCause();
|
||||||
}
|
}
|
||||||
|
|
||||||
nbOutputsLoading.setText("Error fetching fee: " + exception.getMessage());
|
nbOutputsLoading.setText("Error fetching Tx0: " + exception.getMessage());
|
||||||
});
|
});
|
||||||
tx0PreviewsService.start();
|
tx0PreviewsService.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,11 @@ public class WhirlpoolServices {
|
||||||
HostAndPort torProxy = getTorProxy();
|
HostAndPort torProxy = getTorProxy();
|
||||||
whirlpool = new Whirlpool(Network.get(), torProxy);
|
whirlpool = new Whirlpool(Network.get(), torProxy);
|
||||||
whirlpoolMap.put(walletId, whirlpool);
|
whirlpoolMap.put(walletId, whirlpool);
|
||||||
|
} else if(!whirlpool.isStarted()) {
|
||||||
|
HostAndPort torProxy = getTorProxy();
|
||||||
|
if(!Objects.equals(whirlpool.getTorProxy(), torProxy)) {
|
||||||
|
whirlpool.setTorProxy(getTorProxy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return whirlpool;
|
return whirlpool;
|
||||||
|
|
Loading…
Reference in a new issue