diff --git a/build.gradle b/build.gradle
index abf63c2c..c430f175 100644
--- a/build.gradle
+++ b/build.gradle
@@ -69,7 +69,7 @@ dependencies {
exclude group: 'org.openjfx', module: 'javafx-web'
exclude group: 'org.openjfx', module: 'javafx-media'
}
- implementation('dev.bwt:bwt-jni:0.1.6')
+ implementation('dev.bwt:bwt-jni:0.1.7')
testImplementation('junit:junit:4.12')
}
diff --git a/drongo b/drongo
index 3e91bdb4..93d494fc 160000
--- a/drongo
+++ b/drongo
@@ -1 +1 @@
-Subproject commit 3e91bdb46cd235247550b2b579285a05609c0837
+Subproject commit 93d494fcde0d6979b2ded2a9d5ebd5d54d58b8ea
diff --git a/src/main/deploy/package/osx/Info.plist b/src/main/deploy/package/osx/Info.plist
index 6aac8451..c0bb7a42 100644
--- a/src/main/deploy/package/osx/Info.plist
+++ b/src/main/deploy/package/osx/Info.plist
@@ -30,7 +30,7 @@
CFBundleVersion
100
NSHumanReadableCopyright
- Copyright (C) 2020
+ Copyright (C) 2021
NSHighResolutionCapable
true
NSCameraUsageDescription
diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java
index b0391a93..60455fac 100644
--- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java
+++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java
@@ -66,6 +66,9 @@ public class MainApp extends Application {
if(Config.get().getServerType() == null && Config.get().getCoreServer() == null && Config.get().getElectrumServer() != null) {
Config.get().setServerType(ServerType.ELECTRUM_SERVER);
+ } else if(Config.get().getServerType() == ServerType.BITCOIN_CORE && Config.get().getCoreWallet() == null) {
+ Config.get().setCoreMultiWallet(Boolean.TRUE);
+ Config.get().setCoreWallet("");
}
AppController appController = AppServices.newAppWindow(stage);
diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java
index db555c40..94257e08 100644
--- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java
+++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java
@@ -44,6 +44,7 @@ public class Config {
private CoreAuthType coreAuthType;
private File coreDataDir;
private String coreAuth;
+ private Boolean coreMultiWallet;
private String coreWallet;
private String electrumServer;
private File electrumServerCert;
@@ -298,12 +299,21 @@ public class Config {
flush();
}
+ public Boolean getCoreMultiWallet() {
+ return coreMultiWallet;
+ }
+
+ public void setCoreMultiWallet(Boolean coreMultiWallet) {
+ this.coreMultiWallet = coreMultiWallet;
+ flush();
+ }
+
public String getCoreWallet() {
return coreWallet;
}
public void setCoreWallet(String coreWallet) {
- this.coreWallet = (coreWallet == null || coreWallet.isEmpty() ? null : coreWallet);
+ this.coreWallet = coreWallet;
flush();
}
diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java b/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java
index 78aa7e05..934e4a3d 100644
--- a/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java
+++ b/src/main/java/com/sparrowwallet/sparrow/net/Bwt.java
@@ -25,23 +25,29 @@ import java.util.stream.Collectors;
public class Bwt {
private static final Logger log = LoggerFactory.getLogger(Bwt.class);
+
+ public static final String DEFAULT_CORE_WALLET = "sparrow";
private static final int IMPORT_BATCH_SIZE = 350;
+ private static boolean initialized;
private Long shutdownPtr;
private boolean terminating;
private boolean ready;
- static {
- try {
- org.controlsfx.tools.Platform platform = org.controlsfx.tools.Platform.getCurrent();
- if(platform == org.controlsfx.tools.Platform.OSX) {
- NativeUtils.loadLibraryFromJar("/native/osx/x64/libbwt_jni.dylib");
- } else if(platform == org.controlsfx.tools.Platform.WINDOWS) {
- NativeUtils.loadLibraryFromJar("/native/windows/x64/bwt_jni.dll");
- } else {
- NativeUtils.loadLibraryFromJar("/native/linux/x64/libbwt_jni.so");
+ public synchronized static void initialize() {
+ if(!initialized) {
+ try {
+ org.controlsfx.tools.Platform platform = org.controlsfx.tools.Platform.getCurrent();
+ if(platform == org.controlsfx.tools.Platform.OSX) {
+ NativeUtils.loadLibraryFromJar("/native/osx/x64/libbwt_jni.dylib");
+ } else if(platform == org.controlsfx.tools.Platform.WINDOWS) {
+ NativeUtils.loadLibraryFromJar("/native/windows/x64/bwt_jni.dll");
+ } else {
+ NativeUtils.loadLibraryFromJar("/native/linux/x64/libbwt_jni.so");
+ }
+ initialized = true;
+ } catch(IOException e) {
+ log.error("Error loading bwt library", e);
}
- } catch(IOException e) {
- log.error("Error loading bwt library", e);
}
}
@@ -111,9 +117,10 @@ public class Bwt {
} else {
bwtConfig.bitcoindAuth = config.getCoreAuth();
}
- if(config.getCoreWallet() != null && !config.getCoreWallet().isEmpty()) {
+ if(config.getCoreMultiWallet() != Boolean.FALSE) {
bwtConfig.bitcoindWallet = config.getCoreWallet();
}
+ bwtConfig.createWalletIfMissing = true;
Gson gson = new Gson();
String jsonConfig = gson.toJson(bwtConfig);
@@ -178,6 +185,9 @@ public class Bwt {
@SerializedName("bitcoind_wallet")
public String bitcoindWallet;
+ @SerializedName("create_wallet_if_missing")
+ public Boolean createWalletIfMissing;
+
@SerializedName("descriptors")
public List descriptors;
diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java
index fd944c30..6a30436f 100644
--- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java
+++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java
@@ -779,6 +779,7 @@ public class ElectrumServer {
private final Bwt bwt = new Bwt();
private final ReentrantLock bwtStartLock = new ReentrantLock();
private final Condition bwtStartCondition = bwtStartLock.newCondition();
+ private Throwable bwtStartException;
private final StringProperty statusProperty = new SimpleStringProperty();
public ConnectionService() {
@@ -796,10 +797,14 @@ public class ElectrumServer {
ElectrumServer electrumServer = new ElectrumServer();
if(Config.get().getServerType() == ServerType.BITCOIN_CORE) {
+ Bwt.initialize();
+
if(!bwt.isRunning()) {
Bwt.ConnectionService bwtConnectionService = bwt.getConnectionService(subscribe ? AppServices.get().getOpenWallets().keySet() : null);
+ bwtStartException = null;
bwtConnectionService.setOnFailed(workerStateEvent -> {
log.error("Failed to start BWT", workerStateEvent.getSource().getException());
+ bwtStartException = workerStateEvent.getSource().getException();
try {
bwtStartLock.lock();
bwtStartCondition.signal();
@@ -813,8 +818,12 @@ public class ElectrumServer {
bwtStartLock.lock();
bwtStartCondition.await();
- if(!bwt.isRunning()) {
- throw new ServerException("Check if Bitcoin Core is running, and the authentication details are correct.");
+ if(!bwt.isReady()) {
+ if(bwtStartException != null && bwtStartException.getMessage().contains("Wallet file not specified")) {
+ throw new ServerException("Bitcoin Core requires Multi-Wallet to be enabled in the Server Preferences");
+ } else {
+ throw new ServerException("Check if Bitcoin Core is running, and the authentication details are correct.");
+ }
}
} catch(InterruptedException e) {
Thread.currentThread().interrupt();
diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java
index c5af5d14..2bd0863a 100644
--- a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java
@@ -205,10 +205,8 @@ public class ServerPreferencesController extends PreferencesDetailController {
});
coreMultiWallet.selectedProperty().addListener((observable, oldValue, newValue) -> {
- coreWallet.setText(" ");
- coreWallet.setText("");
+ config.setCoreMultiWallet(newValue);
coreWallet.setDisable(!newValue);
- coreWallet.setPromptText(newValue ? "" : "Default");
});
electrumUseSsl.selectedProperty().addListener((observable, oldValue, newValue) -> {
@@ -307,12 +305,15 @@ public class ServerPreferencesController extends PreferencesDetailController {
}
}
- coreMultiWallet.setSelected(true);
- coreMultiWallet.setSelected(config.getCoreWallet() != null);
- if(config.getCoreWallet() != null) {
+ coreWallet.setPromptText("Default");
+ if(config.getCoreWallet() == null) {
+ coreWallet.setText(Bwt.DEFAULT_CORE_WALLET);
+ } else {
coreWallet.setText(config.getCoreWallet());
}
+ coreMultiWallet.setSelected(config.getCoreMultiWallet() != Boolean.FALSE);
+
String electrumServer = config.getElectrumServer();
if(electrumServer != null) {
Protocol protocol = Protocol.getProtocol(electrumServer);
@@ -452,10 +453,6 @@ public class ServerPreferencesController extends PreferencesDetailController {
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Core pass required", coreAuthToggleGroup.getSelectedToggle().getUserData() == CoreAuthType.USERPASS && newValue.isEmpty())
));
- validationSupport.registerValidator(coreWallet, Validator.combine(
- (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Core wallet required", coreMultiWallet.isSelected() && newValue.isEmpty())
- ));
-
validationSupport.registerValidator(electrumHost, Validator.combine(
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Invalid Electrum host", getHost(newValue) == null)
));
diff --git a/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml b/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml
index 8ddcf24b..4acc281c 100644
--- a/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml
+++ b/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml
@@ -89,7 +89,7 @@
-
+
diff --git a/src/main/resources/native/osx/x64/libbwt_jni.dylib b/src/main/resources/native/osx/x64/libbwt_jni.dylib
index 52c7bea1..dbcf6cb8 100755
Binary files a/src/main/resources/native/osx/x64/libbwt_jni.dylib and b/src/main/resources/native/osx/x64/libbwt_jni.dylib differ