cormorant: find cookie dir for non-mainnet networks

This commit is contained in:
Craig Raw 2023-02-08 14:10:20 +02:00
parent 555260e954
commit ff0c381437
2 changed files with 17 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow.net.cormorant.bitcoind; package com.sparrowwallet.sparrow.net.cormorant.bitcoind;
import com.github.arteam.simplejsonrpc.client.Transport; import com.github.arteam.simplejsonrpc.client.Transport;
import com.sparrowwallet.drongo.Network;
import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.io.Server; import com.sparrowwallet.sparrow.io.Server;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -34,7 +35,7 @@ public class BitcoindTransport implements Transport {
public BitcoindTransport(Server bitcoindServer, String bitcoindWallet, File bitcoindDir) { public BitcoindTransport(Server bitcoindServer, String bitcoindWallet, File bitcoindDir) {
this(bitcoindServer, bitcoindWallet); this(bitcoindServer, bitcoindWallet);
this.cookieFile = new File(bitcoindDir, COOKIE_FILENAME); this.cookieFile = new File(getCookieDir(bitcoindDir), COOKIE_FILENAME);
} }
private BitcoindTransport(Server bitcoindServer, String bitcoindWallet) { private BitcoindTransport(Server bitcoindServer, String bitcoindWallet) {
@ -118,6 +119,18 @@ public class BitcoindTransport implements Transport {
return bitcoindAuthEncoded; return bitcoindAuthEncoded;
} }
private static File getCookieDir(File bitcoindDir) {
if(Network.get() == Network.TESTNET && !bitcoindDir.getName().contains("testnet")) {
return new File(bitcoindDir, "testnet3");
} else if(Network.get() == Network.REGTEST && !bitcoindDir.getName().contains("regtest")) {
return new File(bitcoindDir, "regtest");
} else if(Network.get() == Network.SIGNET && !bitcoindDir.getName().contains("signet")) {
return new File(bitcoindDir, "signet");
}
return bitcoindDir;
}
private SSLSocketFactory getTrustAllSocketFactory() { private SSLSocketFactory getTrustAllSocketFactory() {
TrustManager[] trustAllCerts = new TrustManager[] { TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() { new X509TrustManager() {

View file

@ -418,6 +418,9 @@ public class SettingsController extends WalletFormController implements Initiali
Wallet editedWallet = editedOutputDescriptor.toWallet(); Wallet editedWallet = editedOutputDescriptor.toWallet();
editedWallet.setName(getWalletForm().getWallet().getName()); editedWallet.setName(getWalletForm().getWallet().getName());
editedWallet.setBirthDate(getWalletForm().getWallet().getBirthDate());
editedWallet.setGapLimit(getWalletForm().getWallet().getGapLimit());
editedWallet.setWatchLast(getWalletForm().getWallet().getWatchLast());
keystoreTabs.getTabs().removeAll(keystoreTabs.getTabs()); keystoreTabs.getTabs().removeAll(keystoreTabs.getTabs());
totalKeystores.unbind(); totalKeystores.unbind();
totalKeystores.setValue(0); totalKeystores.setValue(0);