From ef3e2ed695ccb7334992f055348d7c1e7ad8b746 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 20 Nov 2023 10:56:06 +0200 Subject: [PATCH] cormorant: handle checking imports and stopping before started --- .../sparrow/net/cormorant/Cormorant.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/Cormorant.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/Cormorant.java index c59b8f93..54219c4c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/Cormorant.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/Cormorant.java @@ -62,6 +62,11 @@ public class Cormorant { } public boolean checkWalletImport(Wallet wallet) { + if(bitcoindClient == null) { + log.warn("Attempting to check if " + wallet.getMasterName() + " is imported, but Cormorant is not started"); + return false; + } + //Will block until all wallet descriptors have been added try { bitcoindClient.importWallet(wallet); @@ -73,6 +78,11 @@ public class Cormorant { } public void checkAddressImport(Address address, Date since) throws ServerException { + if(bitcoindClient == null) { + log.warn("Attempting to check if an address is imported, but Cormorant is not started"); + throw new ServerException("Server is not connected"); + } + //Will block until address descriptor has been added try { bitcoindClient.importAddress(address, since); @@ -86,7 +96,9 @@ public class Cormorant { } public void stop() { - bitcoindClient.stop(); + if(bitcoindClient != null) { + bitcoindClient.stop(); + } if(electrumServer != null) { electrumServer.stop(); }