From 057a9efb1fb1f7584ffe78c4d315913d295f85e9 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 30 Jan 2023 14:46:12 +0200 Subject: [PATCH] cormorant: fix initialisation of sent txes without txindex --- .../sparrow/net/cormorant/bitcoind/BitcoindClient.java | 10 +++++++++- 1 file changed, 9 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 ba36182b..9e7854c3 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 @@ -387,7 +387,7 @@ public class BitcoindClient { for(ListTransaction sentTransaction : sentTransactions) { Set spentOutputs = store.getSpentOutputs().computeIfAbsent(sentTransaction.txid(), txid -> { - String txhex = getBitcoindService().getRawTransaction(txid, false).toString(); + String txhex = getTransaction(txid); Transaction tx = new Transaction(Utils.hexToBytes(txhex)); return tx.getInputs().stream().map(txInput -> new HashIndex(txInput.getOutpoint().getHash(), txInput.getOutpoint().getIndex())).collect(Collectors.toSet()); }); @@ -419,6 +419,14 @@ public class BitcoindClient { } } + private String getTransaction(String txid) { + try { + return getBitcoindService().getTransaction(txid, false).get("hex").toString(); + } catch(JsonRpcException e) { + return getBitcoindService().getRawTransaction(txid, false).toString(); + } + } + private void syncMempool(boolean forceRefresh) { Map mempoolEntries = store.getMempoolEntries();