From bebd7eebe57a6e719f486ec759ca13b8264e43f7 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 14 Aug 2023 10:02:35 +0200 Subject: [PATCH] handle core bug where listwalletdir returns empty results --- .../sparrow/net/cormorant/bitcoind/BitcoindClient.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 3302f1cf..7a88c2f5 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 @@ -141,11 +141,13 @@ public class BitcoindClient { boolean exists = listWalletDirResult.wallets().stream().anyMatch(walletDirResult -> walletDirResult.name().equals(CORE_WALLET_NAME)); legacyWalletExists = listWalletDirResult.wallets().stream().anyMatch(walletDirResult -> walletDirResult.name().equals(Bwt.DEFAULT_CORE_WALLET)); - if(!exists) { + List loadedWallets = getBitcoindService().listWallets(); + boolean loaded = loadedWallets.contains(CORE_WALLET_NAME); + + if(!exists && !loaded) { getBitcoindService().createWallet(CORE_WALLET_NAME, true, true, "", true, true, true, false); } else { - List wallets = getBitcoindService().listWallets(); - if(!wallets.contains(CORE_WALLET_NAME)) { + if(!loaded) { getBitcoindService().loadWallet(CORE_WALLET_NAME, true); } }