From dbafefb940c380db02053666f59288c586222d04 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 31 Oct 2023 10:21:33 +0100 Subject: [PATCH] reload cormorant wallet if unloaded when polling bitcoind --- .../net/cormorant/bitcoind/BitcoindClient.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 7a88c2f5..1fe883fe 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 @@ -157,7 +157,16 @@ public class BitcoindClient { } private ListSinceBlock getListSinceBlock(String blockHash) { - return getBitcoindService().listSinceBlock(blockHash, 1, true, true, true); + try { + return getBitcoindService().listSinceBlock(blockHash, 1, true, true, true); + } catch(JsonRpcException e) { + if(e.getErrorMessage() != null && e.getErrorMessage().getMessage() != null && e.getErrorMessage().getMessage().contains("is not loaded")) { + getBitcoindService().loadWallet(CORE_WALLET_NAME, true); + return getBitcoindService().listSinceBlock(blockHash, 1, true, true, true); + } + + throw e; + } } public void importWallets(Collection wallets) throws ImportFailedException {