Commit 7b8281e8 authored by zeroleak's avatar zeroleak
Browse files

use data suppliers

parent 3b1d9850
......@@ -17,6 +17,8 @@ You can configure a log file in whirlpool-cli-config.properties:
```
logging.file = /tmp/whirlpool-cli.log
```
See this doc for advanced log settings (rotation, limits...):
https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-logging-file-output
#### Testing loop
You can run CLI in loop mode on testnet to generate liquidity on testnet server:
......
......@@ -124,7 +124,11 @@ public class JavaStompClient implements IStompClient {
byte[] payload,
Throwable exception) {
super.handleException(session, command, headers, payload, exception);
log.error(" ! transportException", exception);
log.error(
" ! transportException: "
+ exception.getClass().getName()
+ ": "
+ exception.getMessage());
}
@Override
......@@ -134,10 +138,6 @@ public class JavaStompClient implements IStompClient {
" ! transportError: " + exception.getClass().getName() + ": " + exception.getMessage());
disconnect();
onConnectOnDisconnectListener.onError(exception);
if (log.isDebugEnabled()) {
log.error("", exception);
}
}
};
}
......
......@@ -56,10 +56,7 @@ public class Application implements ApplicationRunner {
// run
WebApplicationType wat = listen ? WebApplicationType.SERVLET : WebApplicationType.NONE;
applicationContext =
new SpringApplicationBuilder(Application.class)
.logStartupInfo(debugClient)
.web(wat)
.run(args);
new SpringApplicationBuilder(Application.class).logStartupInfo(false).web(wat).run(args);
if (restart) {
// restart
......
......@@ -9,7 +9,6 @@ import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import com.samourai.whirlpool.client.wallet.beans.Tx0FeeTarget;
import com.samourai.whirlpool.client.whirlpool.beans.Pool;
import java.util.Collection;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
......@@ -27,8 +26,7 @@ public class PoolsController extends AbstractRestController {
throws Exception {
checkHeaders(headers);
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
Collection<Pool> pools = whirlpoolWallet.getPools(false);
Map<String, Long> overspendPerPool = cliConfig.getMix().getOverspend();
return new ApiPoolsResponse(pools, tx0FeeTarget, whirlpoolWallet, overspendPerPool);
Collection<Pool> pools = whirlpoolWallet.getPoolSupplier().getPools();
return new ApiPoolsResponse(pools, tx0FeeTarget, whirlpoolWallet);
}
}
......@@ -24,7 +24,8 @@ public class UtxoController extends AbstractRestController {
private WhirlpoolUtxo findUtxo(String utxoHash, int utxoIndex) throws Exception {
// find utxo
WhirlpoolUtxo whirlpoolUtxo = cliWalletService.getSessionWallet().findUtxo(utxoHash, utxoIndex);
WhirlpoolUtxo whirlpoolUtxo =
cliWalletService.getSessionWallet().getUtxoSupplier().findUtxo(utxoHash, utxoIndex);
if (whirlpoolUtxo == null) {
throw new NotifiableException("Utxo not found: " + utxoHash + ":" + utxoIndex);
}
......@@ -68,13 +69,13 @@ public class UtxoController extends AbstractRestController {
WhirlpoolUtxo whirlpoolUtxo = findUtxo(utxoHash, utxoIndex);
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
Pool pool = whirlpoolWallet.findPoolById(payload.poolId);
Pool pool = whirlpoolWallet.getPoolSupplier().findPoolById(payload.poolId);
if (pool == null) {
throw new NotifiableException("poolId is not valid");
}
// tx0 preview
Tx0Config tx0Config = whirlpoolWallet.getTx0Config(pool);
Tx0Config tx0Config = whirlpoolWallet.getTx0Config();
Tx0Preview tx0Preview =
whirlpoolWallet.tx0Preview(Lists.of(whirlpoolUtxo), pool, tx0Config, payload.feeTarget);
return new ApiTx0PreviewResponse(tx0Preview);
......@@ -98,13 +99,13 @@ public class UtxoController extends AbstractRestController {
whirlpoolWallet.setMixsTarget(whirlpoolUtxo, payload.mixsTarget);
}
Pool pool = whirlpoolWallet.findPoolById(payload.poolId);
Pool pool = whirlpoolWallet.getPoolSupplier().findPoolById(payload.poolId);
if (pool == null) {
throw new NotifiableException("poolId is not valid");
}
// tx0
Tx0Config tx0Config = whirlpoolWallet.getTx0Config(pool);
Tx0Config tx0Config = whirlpoolWallet.getTx0Config();
Tx0 tx0 = whirlpoolWallet.tx0(Lists.of(whirlpoolUtxo), pool, payload.feeTarget, tx0Config);
return new ApiTx0Response(tx0);
}
......
......@@ -33,7 +33,6 @@ public class ApiUtxo {
this.path = utxo.xpub.path;
this.account = whirlpoolUtxo.getAccount();
WhirlpoolUtxoConfig utxoConfig = whirlpoolUtxo.getUtxoConfig();
WhirlpoolUtxoState utxoState = whirlpoolUtxo.getUtxoState();
this.status = utxoState.getStatus();
this.mixStep =
......@@ -41,10 +40,10 @@ public class ApiUtxo {
this.mixableStatus = utxoState.getMixableStatus();
this.progressPercent =
utxoState.getMixProgress() != null ? utxoState.getMixProgress().getProgressPercent() : null;
this.poolId = utxoConfig.getPoolId();
this.mixsTarget = utxoConfig.getMixsTarget();
this.mixsTargetOrDefault = utxoConfig.getMixsTargetOrDefault(mixsTargetMin);
this.mixsDone = utxoConfig.getMixsDone();
this.poolId = whirlpoolUtxo.getPoolId();
this.mixsTarget = whirlpoolUtxo.getMixsTarget();
this.mixsTargetOrDefault = whirlpoolUtxo.getMixsTargetOrDefault(mixsTargetMin);
this.mixsDone = whirlpoolUtxo.getMixsDone();
this.message = utxoState.getMessage();
this.error = utxoState.getError();
this.lastActivityElapsed =
......
......@@ -5,33 +5,23 @@ import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import com.samourai.whirlpool.client.wallet.beans.Tx0FeeTarget;
import com.samourai.whirlpool.client.whirlpool.beans.Pool;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;
public class ApiPoolsResponse {
private Collection<ApiPool> pools;
public ApiPoolsResponse(
Collection<Pool> pools,
Tx0FeeTarget feeTarget,
WhirlpoolWallet whirlpoolWallet,
Map<String, Long> overspendPerPool) {
Collection<Pool> pools, Tx0FeeTarget feeTarget, WhirlpoolWallet whirlpoolWallet) {
this.pools =
pools
.stream()
.map(
pool -> {
Long overspendOrNull =
overspendPerPool != null ? overspendPerPool.get(pool.getPoolId()) : null;
return computeApiPool(pool, feeTarget, whirlpoolWallet, overspendOrNull);
})
.map(pool -> computeApiPool(pool, feeTarget, whirlpoolWallet))
.collect(Collectors.toList());
}
private ApiPool computeApiPool(
Pool pool, Tx0FeeTarget feeTarget, WhirlpoolWallet whirlpoolWallet, Long overspendOrNull) {
long tx0BalanceMin =
whirlpoolWallet.computeTx0SpendFromBalanceMin(pool, feeTarget, 1, overspendOrNull);
Pool pool, Tx0FeeTarget feeTarget, WhirlpoolWallet whirlpoolWallet) {
long tx0BalanceMin = whirlpoolWallet.computeTx0SpendFromBalanceMin(pool, feeTarget);
return new ApiPool(pool, tx0BalanceMin);
}
......
......@@ -3,8 +3,10 @@ package com.samourai.whirlpool.cli.api.protocol.rest;
import com.google.common.primitives.Ints;
import com.samourai.whirlpool.cli.api.protocol.beans.ApiWallet;
import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolAccount;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxoState;
import java.util.Collection;
import java.util.Comparator;
import java8.lang.Longs;
......@@ -35,25 +37,19 @@ public class ApiWalletUtxosResponse {
// last confirmed
return Ints.compare(o1.getUtxo().confirmations, o2.getUtxo().confirmations);
};
this.deposit = computeApiWallet(WhirlpoolAccount.DEPOSIT, whirlpoolWallet, comparator);
this.premix = computeApiWallet(WhirlpoolAccount.PREMIX, whirlpoolWallet, comparator);
this.postmix = computeApiWallet(WhirlpoolAccount.POSTMIX, whirlpoolWallet, comparator);
}
private ApiWallet computeApiWallet(
WhirlpoolAccount account,
WhirlpoolWallet whirlpoolWallet,
Comparator<WhirlpoolUtxo> comparator) {
Collection<WhirlpoolUtxo> utxos = whirlpoolWallet.getUtxoSupplier().findUtxos(account);
String zpub = whirlpoolWallet.getWalletSupplier().getWallet(account).getZpub();
int mixsTargetMin = whirlpoolWallet.getConfig().getMixsTarget();
this.deposit =
new ApiWallet(
whirlpoolWallet.getUtxosDeposit(),
whirlpoolWallet.getZpubDeposit(),
comparator,
mixsTargetMin);
this.premix =
new ApiWallet(
whirlpoolWallet.getUtxosPremix(),
whirlpoolWallet.getZpubPremix(),
comparator,
mixsTargetMin);
this.postmix =
new ApiWallet(
whirlpoolWallet.getUtxosPostmix(),
whirlpoolWallet.getZpubPostmix(),
comparator,
mixsTargetMin);
return new ApiWallet(utxos, zpub, comparator, mixsTargetMin);
}
public ApiWallet getDeposit() {
......
......@@ -8,7 +8,6 @@ import com.samourai.wallet.api.backend.BackendServer;
import com.samourai.wallet.util.FormatsUtilGeneric;
import com.samourai.whirlpool.client.utils.ClientUtils;
import com.samourai.whirlpool.client.wallet.WhirlpoolWalletConfig;
import com.samourai.whirlpool.client.wallet.persist.WhirlpoolWalletPersistHandler;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
......@@ -29,7 +28,6 @@ public class CliConfig extends CliConfigFile {
public WhirlpoolWalletConfig computeWhirlpoolWalletConfig(
IHttpClientService httpClientService,
IStompClientService stompClientService,
WhirlpoolWalletPersistHandler persistHandler,
BackendApi backendApi) {
// check valid
......@@ -38,8 +36,7 @@ public class CliConfig extends CliConfigFile {
}
WhirlpoolWalletConfig config =
super.computeWhirlpoolWalletConfig(
httpClientService, stompClientService, persistHandler, backendApi);
super.computeWhirlpoolWalletConfig(httpClientService, stompClientService, backendApi);
config.setAutoTx0PoolId(autoTx0PoolId);
return config;
}
......
......@@ -9,7 +9,7 @@ import com.samourai.whirlpool.cli.utils.CliUtils;
import com.samourai.whirlpool.client.utils.ClientUtils;
import com.samourai.whirlpool.client.wallet.WhirlpoolWalletConfig;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolServer;
import com.samourai.whirlpool.client.wallet.persist.WhirlpoolWalletPersistHandler;
import com.samourai.whirlpool.client.whirlpool.ServerApi;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
......@@ -33,8 +33,6 @@ public abstract class CliConfigFile {
@NotEmpty private String apiKey;
@NotEmpty private String seed;
@NotEmpty private boolean seedAppendPassphrase;
@NotEmpty private int persistDelay;
@NotEmpty private int refreshPoolsDelay;
@NotEmpty private int tx0MinConfirmations;
@NotEmpty private String proxy;
......@@ -63,8 +61,6 @@ public abstract class CliConfigFile {
this.apiKey = copy.apiKey;
this.seed = copy.seed;
this.seedAppendPassphrase = copy.seedAppendPassphrase;
this.persistDelay = copy.persistDelay;
this.refreshPoolsDelay = copy.refreshPoolsDelay;
this.tx0MinConfirmations = copy.tx0MinConfirmations;
this.proxy = copy.proxy;
this.requestTimeout = copy.requestTimeout;
......@@ -144,22 +140,6 @@ public abstract class CliConfigFile {
this.seedAppendPassphrase = seedAppendPassphrase;
}
public int getPersistDelay() {
return persistDelay;
}
public void setPersistDelay(int persistDelay) {
this.persistDelay = persistDelay;
}
public int getRefreshPoolsDelay() {
return refreshPoolsDelay;
}
public void setRefreshPoolsDelay(int refreshPoolsDelay) {
this.refreshPoolsDelay = refreshPoolsDelay;
}
public int getTx0MinConfirmations() {
return tx0MinConfirmations;
}
......@@ -523,32 +503,26 @@ public abstract class CliConfigFile {
protected WhirlpoolWalletConfig computeWhirlpoolWalletConfig(
IHttpClientService httpClientService,
IStompClientService stompClientService,
WhirlpoolWalletPersistHandler persistHandler,
BackendApi backendApi) {
String serverUrl = computeServerUrl();
NetworkParameters params = server.getParams();
ServerApi serverApi = new ServerApi(serverUrl, httpClientService);
WhirlpoolWalletConfig config =
new WhirlpoolWalletConfig(
httpClientService,
stompClientService,
persistHandler,
serverUrl,
params,
false,
backendApi);
httpClientService, stompClientService, serverApi, params, false, backendApi);
if (!Strings.isEmpty(scode)) {
config.setScode(scode);
}
config.setPersistDelay(persistDelay);
config.setRefreshPoolsDelay(refreshPoolsDelay);
config.setTx0MinConfirmations(tx0MinConfirmations);
config.setMaxClients(mix.getClients());
config.setMaxClientsPerPool(mix.getClientsPerPool());
config.setClientDelay(mix.getClientDelay());
config.setTx0Delay(mix.getTx0Delay());
config.setTx0MaxOutputs(mix.getTx0MaxOutputs());
config.setAutoMix(mix.isAutoMix());
config.setMixsTarget(mix.getMixsTarget());
config.setOverspend(mix.getOverspend());
return config;
}
......@@ -566,8 +540,6 @@ public abstract class CliConfigFile {
}
configInfo.put("cli/apiKey", ClientUtils.maskString(apiKey));
configInfo.put("cli/seedEncrypted", ClientUtils.maskString(seed));
configInfo.put("cli/persistDelay", Integer.toString(persistDelay));
configInfo.put("cli/refreshPoolsDelay", Integer.toString(refreshPoolsDelay));
configInfo.put("cli/tx0MinConfirmations", Integer.toString(tx0MinConfirmations));
configInfo.put("cli/proxy", proxy != null ? ClientUtils.maskString(proxy) : "null");
configInfo.putAll(mix.getConfigInfo());
......
......@@ -7,6 +7,7 @@ import com.samourai.whirlpool.cli.utils.CliUtils;
import com.samourai.whirlpool.client.utils.ClientUtils;
import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import com.samourai.whirlpool.client.wallet.beans.MixingState;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolAccount;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo;
import com.samourai.whirlpool.client.wallet.orchestrator.AbstractOrchestrator;
import java.util.Collection;
......@@ -42,14 +43,11 @@ public class CliStatusInteractiveOrchestrator extends AbstractOrchestrator {
if (car.equals('T')) {
printThreads();
} else if (car.equals('D')) {
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
printUtxos("DEPOSIT", whirlpoolWallet.getUtxosDeposit());
printUtxos(WhirlpoolAccount.DEPOSIT);
} else if (car.equals('P')) {
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
printUtxos("PREMIX", whirlpoolWallet.getUtxosPremix());
printUtxos(WhirlpoolAccount.PREMIX);
} else if (car.equals('O')) {
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
printUtxos("POSTMIX", whirlpoolWallet.getUtxosPostmix());
printUtxos(WhirlpoolAccount.POSTMIX);
} else if (car.equals('S')) {
printSystem();
}
......@@ -72,13 +70,7 @@ public class CliStatusInteractiveOrchestrator extends AbstractOrchestrator {
log.info("⣿ MIXING THREADS:");
int i = 0;
for (WhirlpoolUtxo whirlpoolUtxo : mixingState.getUtxosMixing()) {
log.info(
"⣿ Thread #"
+ (i + 1)
+ ": MIXING "
+ whirlpoolUtxo.toString()
+ " ; "
+ whirlpoolUtxo.getUtxoConfig());
log.info("⣿ Thread #" + (i + 1) + ": MIXING " + whirlpoolUtxo.toString());
i++;
}
} catch (NoSessionWalletException e) {
......@@ -117,10 +109,12 @@ public class CliStatusInteractiveOrchestrator extends AbstractOrchestrator {
log.info("⣿ MEM USE: " + CliUtils.bytesToMB(used) + "M/" + CliUtils.bytesToMB(total) + "M");
}
private void printUtxos(String account, Collection<WhirlpoolUtxo> utxos) {
private void printUtxos(WhirlpoolAccount account) throws Exception {
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
Collection<WhirlpoolUtxo> utxos = whirlpoolWallet.getUtxoSupplier().findUtxos(account);
try {
log.info("⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿");
log.info("⣿ " + account + " UTXOS:");
log.info("⣿ " + account.name() + " UTXOS:");
ClientUtils.logWhirlpoolUtxos(utxos, cliConfig.getMix().getMixsTarget());
} catch (Exception e) {
......
package com.samourai.whirlpool.cli.run;
import com.samourai.wallet.client.Bip84ApiWallet;
import com.samourai.wallet.client.Bip84Wallet;
import com.samourai.whirlpool.cli.ApplicationArgs;
import com.samourai.whirlpool.cli.config.CliConfig;
import com.samourai.whirlpool.cli.services.CliWalletService;
......@@ -38,7 +38,7 @@ public class RunCliCommand {
// should we move to a specific address?
String toAddress = appArgs.getAggregatePostmix();
if (toAddress != null && !"true".equals(toAddress)) {
Bip84ApiWallet depositWallet = cliWallet.getWalletDeposit();
Bip84Wallet depositWallet = cliWallet.getWalletDeposit();
log.info(" • Moving funds to: " + toAddress);
walletAggregateService.toAddress(depositWallet, toAddress, cliWallet);
}
......
......@@ -18,7 +18,7 @@ public class RunListPools {
}
public void run() throws Exception {
Collection<Pool> pools = cliWallet.getPools(true);
Collection<Pool> pools = cliWallet.getPoolSupplier().getPools();
// show available pools
String lineFormat = "| %15s | %6s | %15s | %14s | %12s | %15s | %23s |\n";
......
......@@ -228,11 +228,6 @@ public class CliService {
log.debug("shutdown");
}
// stop cliStatusOrchestrator
if (cliStatusOrchestrator != null) {
cliStatusOrchestrator.stop();
}
// stop cliWallet
try {
CliWallet cliWallet =
......@@ -249,5 +244,10 @@ public class CliService {
if (cliTorClientService != null) {
cliTorClientService.shutdown();
}
// stop cliStatusOrchestrator
if (cliStatusOrchestrator != null) {
cliStatusOrchestrator.stop();
}
}
}
......@@ -29,8 +29,6 @@ import com.samourai.whirlpool.client.wallet.WhirlpoolDataService;
import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import com.samourai.whirlpool.client.wallet.WhirlpoolWalletConfig;
import com.samourai.whirlpool.client.wallet.WhirlpoolWalletService;
import com.samourai.whirlpool.client.wallet.persist.FileWhirlpoolWalletPersistHandler;
import com.samourai.whirlpool.client.wallet.persist.WhirlpoolWalletPersistHandler;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.Map;
......@@ -120,21 +118,23 @@ public class CliWalletService extends WhirlpoolWalletService {
}
// backend connexion
BackendApi BackendApiService = computeBackendApiService(passphrase);
if (!BackendApiService.testConnectivity()) {
BackendApi backendApiService = computeBackendApiService(passphrase);
if (!backendApiService.testConnectivity()) {
throw new NotifiableException(
"Unable to connect to wallet backend: " + BackendApiService.getUrlBackend());
"Unable to connect to wallet backend: " + backendApiService.getUrlBackend());
}
// open wallet
WhirlpoolWalletPersistHandler persistHandler = computePersistHandler(walletIdentifier);
WhirlpoolWalletConfig whirlpoolWalletConfig =
WhirlpoolWalletConfig config =
cliConfig.computeWhirlpoolWalletConfig(
httpClientService, stompClientService, persistHandler, BackendApiService);
WhirlpoolDataService whirlpoolDataService =
new WhirlpoolDataService(whirlpoolWalletConfig, this);
httpClientService, stompClientService, backendApiService);
String walletStateFileName = computeIndexFile(walletIdentifier).getAbsolutePath();
String utxoConfigFileName = computeUtxosFile(walletIdentifier).getAbsolutePath();
WhirlpoolDataService dataService = new WhirlpoolDataService(config);
WhirlpoolWallet whirlpoolWallet =
computeWhirlpoolWallet(whirlpoolWalletConfig, whirlpoolDataService, bip84w);
computeWhirlpoolWallet(dataService, bip84w, walletStateFileName, utxoConfigFileName);
CliWallet cliWallet =
new CliWallet(
whirlpoolWallet,
......@@ -160,15 +160,6 @@ public class CliWalletService extends WhirlpoolWalletService {
return new BackendApi(httpClient, backendUrl, oAuthManager);
}
private WhirlpoolWalletPersistHandler computePersistHandler(String walletIdentifier)
throws NotifiableException {
File indexFile = computeIndexFile(walletIdentifier);
File utxosFile = computeUtxosFile(walletIdentifier);
WhirlpoolWalletPersistHandler persistHandler =
new FileWhirlpoolWalletPersistHandler(indexFile, utxosFile);
return persistHandler;
}
protected String decryptSeedWords(String seedWordsEncrypted, String seedPassphrase)
throws Exception {
return AESUtil.decrypt(seedWordsEncrypted, new CharSequenceX(seedPassphrase));
......@@ -198,17 +189,11 @@ public class CliWalletService extends WhirlpoolWalletService {
private File computeIndexFile(String walletIdentifier) throws NotifiableException {
String path = "whirlpool-cli-state-" + walletIdentifier + ".json";
if (log.isDebugEnabled()) {
log.debug("indexFile: " + path);
}
return CliUtils.computeFile(path);
}
private File computeUtxosFile(String walletIdentifier) throws NotifiableException {
String path = "whirlpool-cli-utxos-" + walletIdentifier + ".json";
if (log.isDebugEnabled()) {
log.debug("utxosFile: " + path);
}
return CliUtils.computeFile(path);
}
......
......@@ -30,6 +30,7 @@ public class JavaHttpClientService implements IHttpClientService {
this.httpClients = new ConcurrentHashMap<>();
}
@Override
public JavaHttpClient getHttpClient(HttpUsage httpUsage) {
JavaHttpClient httpClient = httpClients.get(httpUsage);
if (httpClient == null) {
......
......@@ -3,7 +3,6 @@ package com.samourai.whirlpool.cli.services;
import com.samourai.wallet.api.backend.BackendApi;
import com.samourai.wallet.api.backend.MinerFeeTarget;
import com.samourai.wallet.api.backend.beans.UnspentResponse;
import com.samourai.wallet.client.Bip84ApiWallet;
import com.samourai.wallet.client.Bip84Wallet;
import com.samourai.wallet.hd.HD_Address;
import com.samourai.wallet.segwit.bech32.Bech32UtilGeneric;
......@@ -12,6 +11,7 @@ import com.samourai.whirlpool.cli.config.CliConfig;
import com.samourai.whirlpool.cli.wallet.CliWallet;
import com.samourai.whirlpool.client.exception.NotifiableException;
import com.samourai.whirlpool.client.utils.ClientUtils;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolAccount;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.List;
......@@ -44,8 +44,8 @@ public class WalletAggregateService {
this.txAggregateService = txAggregateService;
}
public boolean toWallet(
Bip84ApiWallet sourceWallet,
private boolean toWallet(
Bip84Wallet sourceWallet,
Bip84Wallet destinationWallet,
int feeSatPerByte,
BackendApi backendApi)
......@@ -53,27 +53,26 @@ public class WalletAggregateService {
return doAggregate(sourceWallet, null, destinationWallet, feeSatPerByte, backendApi);
}
public boolean toAddress(
Bip84ApiWallet sourceWallet, String destinationAddress, CliWallet cliWallet)
public boolean toAddress(Bip84Wallet sourceWallet, String destinationAddress, CliWallet cliWallet)
throws Exception {
if (!formatUtils.isTestNet(cliConfig.getServer().getParams())) {
throw new NotifiableException(
"aggregate toAddress is disabled on mainnet for security reasons.");
}
int feeSatPerByte = cliWallet.getFee(MinerFeeTarget.BLOCKS_2);
int feeSatPerByte = cliWallet.getMinerFeeSupplier().getFee(MinerFeeTarget.BLOCKS_2);
BackendApi backendApi = cliWallet.getConfig().getBackendApi();
return doAggregate(sourceWallet, destinationAddress, null, feeSatPerByte, backendApi);
}