From db1b55cfa0008e5c740639881eb7c468b1a3c728 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 14 Jan 2025 15:12:39 +0200 Subject: [PATCH] cormorant: report configuration error when both core data folder and user/pass is not specified --- .../sparrow/net/ConfigurationException.java | 11 +++++++++++ .../net/cormorant/bitcoind/BitcoindClient.java | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/sparrowwallet/sparrow/net/ConfigurationException.java diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ConfigurationException.java b/src/main/java/com/sparrowwallet/sparrow/net/ConfigurationException.java new file mode 100644 index 00000000..9057125d --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/net/ConfigurationException.java @@ -0,0 +1,11 @@ +package com.sparrowwallet.sparrow.net; + +public class ConfigurationException extends RuntimeException { + public ConfigurationException(String message) { + super(message); + } + + public ConfigurationException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java index 2934e35f..caede21d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClient.java @@ -17,6 +17,7 @@ import com.sparrowwallet.sparrow.event.CormorantScanStatusEvent; import com.sparrowwallet.sparrow.event.CormorantSyncStatusEvent; import com.sparrowwallet.sparrow.io.Config; import com.sparrowwallet.sparrow.net.Bwt; +import com.sparrowwallet.sparrow.net.ConfigurationException; import com.sparrowwallet.sparrow.net.CoreAuthType; import com.sparrowwallet.sparrow.net.cormorant.Cormorant; import com.sparrowwallet.drongo.address.Address; @@ -94,8 +95,10 @@ public class BitcoindClient { Config config = Config.get(); if((config.getCoreAuthType() == CoreAuthType.COOKIE || config.getCoreAuth() == null || config.getCoreAuth().length() < 2) && config.getCoreDataDir() != null) { bitcoindTransport = new BitcoindTransport(config.getCoreServer(), CORE_WALLET_NAME, config.getCoreDataDir()); - } else { + } else if(config.getCoreAuth() != null) { bitcoindTransport = new BitcoindTransport(config.getCoreServer(), CORE_WALLET_NAME, config.getCoreAuth()); + } else { + throw new ConfigurationException("Bitcoin Core data folder or user and password is required"); } this.jsonRpcClient = new JsonRpcClient(bitcoindTransport);