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 0152f828..688f3b8f 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 @@ -383,10 +383,10 @@ public class BitcoindClient { for(String txid : new HashSet<>(mempoolEntries.keySet())) { if(forceRefresh || mempoolEntries.get(txid) == null) { - MempoolEntry mempoolEntry = getBitcoindService().getMempoolEntry(txid); - if(mempoolEntry != null) { + try { + MempoolEntry mempoolEntry = getBitcoindService().getMempoolEntry(txid); mempoolEntries.put(txid, mempoolEntry); - } else { + } catch(JsonRpcException e) { mempoolEntries.remove(txid); } } @@ -395,7 +395,14 @@ public class BitcoindClient { private boolean isConflicted(ListTransaction listTransaction, Map conflictCache) { if(listTransaction.confirmations() == 0 && !listTransaction.walletconflicts().isEmpty()) { - Boolean active = conflictCache.computeIfAbsent(listTransaction.txid(), txid -> getBitcoindService().getMempoolEntry(txid) != null); + Boolean active = conflictCache.computeIfAbsent(listTransaction.txid(), txid -> { + try { + getBitcoindService().getMempoolEntry(txid); + return true; + } catch(JsonRpcException e) { + return false; + } + }); if(active) { for(String conflictedTxid : listTransaction.walletconflicts()) { diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumNotificationService.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumNotificationService.java index addc7ea2..6414b8f0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumNotificationService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumNotificationService.java @@ -1,6 +1,7 @@ package com.sparrowwallet.sparrow.net.cormorant.electrum; import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcMethod; +import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcOptional; import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcParam; import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcService; @@ -10,5 +11,5 @@ public interface ElectrumNotificationService { void notifyHeaders(@JsonRpcParam("header") ElectrumBlockHeader electrumBlockHeader); @JsonRpcMethod("blockchain.scripthash.subscribe") - void notifyScriptHash(@JsonRpcParam("scripthash") String scriptHash, @JsonRpcParam("status") String status); + void notifyScriptHash(@JsonRpcParam("scripthash") String scriptHash, @JsonRpcOptional @JsonRpcParam("status") String status); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java index ca5d5572..9d5a22cd 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java @@ -146,9 +146,9 @@ public class ElectrumServerService { } @JsonRpcMethod("blockchain.transaction.get") - public String getTransaction(@JsonRpcParam("tx_hash") String tx_hash, @JsonRpcParam("verbose") @JsonRpcOptional boolean verbose) throws BitcoindIOException, TransactionNotFoundException { + public Object getTransaction(@JsonRpcParam("tx_hash") String tx_hash, @JsonRpcParam("verbose") @JsonRpcOptional boolean verbose) throws BitcoindIOException, TransactionNotFoundException { try { - return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, verbose).toString(); + return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, verbose); } catch(JsonRpcException e) { throw new TransactionNotFoundException(e.getErrorMessage()); } catch(IllegalStateException e) {