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 df3935bd..ba36182b 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 @@ -128,18 +128,11 @@ public class BitcoindClient { legacyWalletExists = listWalletDirResult.wallets().stream().anyMatch(walletDirResult -> walletDirResult.name().equals(Bwt.DEFAULT_CORE_WALLET)); if(!exists) { - getBitcoindService().createWallet(CORE_WALLET_NAME, true, true, "", true, true, false, false); + getBitcoindService().createWallet(CORE_WALLET_NAME, true, true, "", true, true, true, false); } else { - try { - getBitcoindService().loadWallet(CORE_WALLET_NAME, false); - } catch(JsonRpcException e) { - try { - getBitcoindService().unloadWallet(CORE_WALLET_NAME, false); - } catch(JsonRpcException ex) { - //ignore - } - - getBitcoindService().loadWallet(CORE_WALLET_NAME, false); + List wallets = getBitcoindService().listWallets(); + if(!wallets.contains(CORE_WALLET_NAME)) { + getBitcoindService().loadWallet(CORE_WALLET_NAME, true); } } @@ -346,14 +339,6 @@ public class BitcoindClient { } public void stop() { - if(initialized) { - try { - getBitcoindService().unloadWallet(CORE_WALLET_NAME, false); - } catch(Exception e) { - log.info("Error unloading Core wallet " + CORE_WALLET_NAME, e); - } - } - timer.cancel(); stopped = true; } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java index d702a4e5..8f978111 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindClientService.java @@ -57,6 +57,9 @@ public interface BitcoindClientService { @JsonRpcMethod("listwalletdir") ListWalletDirResult listWalletDir(); + @JsonRpcMethod("listwallets") + List listWallets(); + @JsonRpcMethod("createwallet") CreateLoadWalletResult createWallet(@JsonRpcParam("wallet_name") String name, @JsonRpcParam("disable_private_keys") boolean disablePrivateKeys, @JsonRpcParam("blank") boolean blank, @JsonRpcParam("passphrase") String passphrase, @JsonRpcParam("avoid_reuse") boolean avoidReuse, @JsonRpcParam("descriptors") boolean descriptors,