Merge pull request #1369 from zeroleak/whirlpool-1.0.6

upgrade to whirlpool 1.0.6 to support simpler onion switching
This commit is contained in:
craigraw 2024-04-10 10:34:47 +02:00 committed by GitHub
commit 594a873f20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 25 deletions

View file

@ -124,7 +124,7 @@ dependencies {
exclude group: 'org.slf4j'
}
implementation('com.sparrowwallet.bokmakierie:bokmakierie:1.0')
implementation('io.samourai.code.whirlpool:whirlpool-client:1.0.5')
implementation('io.samourai.code.whirlpool:whirlpool-client:1.0.6')
implementation('io.samourai.code.wallet:java-http-client:2.0.2')
implementation('io.reactivex.rxjava2:rxjava:2.2.15')
implementation('io.reactivex.rxjava2:rxjavafx:2.2.2')

View file

@ -3,6 +3,7 @@ package com.sparrowwallet.sparrow.soroban;
import com.samourai.soroban.client.SorobanConfig;
import com.samourai.soroban.client.wallet.SorobanWalletService;
import com.samourai.wallet.hd.HD_Wallet;
import com.samourai.wallet.util.ExtLibJConfig;
import com.sparrowwallet.drongo.Network;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.Wallet;
@ -37,7 +38,8 @@ public class Soroban {
}
public void setHDWallet(Wallet wallet) {
NetworkParameters params = sorobanWalletService.getSorobanService().getParams();
ExtLibJConfig extLibJConfig = sorobanWalletService.getSorobanService().getSorobanConfig().getExtLibJConfig();
NetworkParameters params = extLibJConfig.getSamouraiNetwork().getParams();
hdWallet = Whirlpool.computeHdWallet(wallet, params);
bip47Account = wallet.isMasterWallet() ? wallet.getAccountIndex() : wallet.getMasterWallet().getAccountIndex();
}

View file

@ -112,18 +112,6 @@ public class Whirlpool {
return whirlpoolWalletConfig;
}
void setOnion(boolean onion) {
if(config.isTorOnionCoordinator() ^ onion) {
try {
Field torField = WhirlpoolClientConfig.class.getDeclaredField("torOnionCoordinator");
torField.setAccessible(true);
torField.set(config, onion);
} catch(Exception e) {
log.warn("Error changing onion on WhirlpoolWalletConfig", e);
}
}
}
private DataSourceConfig computeDataSourceConfig(Integer storedBlockHeight) {
return new DataSourceConfig(SparrowMinerFeeSupplier.getInstance(), new SparrowChainSupplier(storedBlockHeight), BIP_FORMAT.PROVIDER, BIP_WALLETS.WHIRLPOOL);
}

View file

@ -110,8 +110,6 @@ public class WhirlpoolServices {
public void startWhirlpool(Wallet wallet, Whirlpool whirlpool, boolean notifyIfMixToMissing) {
if(wallet.getMasterMixConfig().getMixOnStartup() != Boolean.FALSE) {
whirlpool.setOnion(sorobanConfig.getExtLibJConfig().isOnion());
try {
String mixToWalletId = getWhirlpoolMixToWalletId(wallet.getMasterMixConfig());
whirlpool.setMixToWallet(mixToWalletId, wallet.getMasterMixConfig().getMinMixes());
@ -230,14 +228,6 @@ public class WhirlpoolServices {
extLibJConfig.setOnion(getTorProxy() != null);
getHttpClientService(); //Ensure proxy is updated
try {
Field onionField = RpcClientService.class.getDeclaredField("onion");
onionField.setAccessible(true);
onionField.set(sorobanConfig.getRpcClientService(), getTorProxy() != null);
} catch(Exception e) {
log.warn("Error changing onion on RpcClientService", e);
}
startAllWhirlpool();
bindDebugAccelerator();
}

View file

@ -8,6 +8,7 @@ import com.samourai.wallet.api.backend.seenBackend.SeenBackendWithFallback;
import com.samourai.wallet.hd.HD_Wallet;
import com.samourai.wallet.httpClient.HttpUsage;
import com.samourai.wallet.httpClient.IHttpClient;
import com.samourai.wallet.util.ExtLibJConfig;
import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import com.samourai.whirlpool.client.wallet.WhirlpoolWalletConfig;
import com.samourai.whirlpool.client.wallet.data.coordinator.CoordinatorSupplier;
@ -57,7 +58,8 @@ public class SparrowDataSource extends AbstractDataSource {
}
private ISeenBackend computeSeenBackend(WhirlpoolWalletConfig whirlpoolWalletConfig) {
IHttpClient httpClient = whirlpoolWalletConfig.getHttpClient(HttpUsage.BACKEND);
ExtLibJConfig extLibJConfig = whirlpoolWalletConfig.getSorobanConfig().getExtLibJConfig();
IHttpClient httpClient = extLibJConfig.getHttpClientService().getHttpClient(HttpUsage.BACKEND);
ISeenBackend sparrowSeenBackend = new SparrowSeenBackend(getWhirlpoolWallet().getWalletIdentifier(), httpClient);
NetworkParameters params = whirlpoolWalletConfig.getSamouraiNetwork().getParams();
return SeenBackendWithFallback.withOxt(sparrowSeenBackend, params);