diff --git a/core/src/main/java/org/bitcoinj/core/Transaction.java b/core/src/main/java/org/bitcoinj/core/Transaction.java index 0d4d7bc1631..381488d2660 100644 --- a/core/src/main/java/org/bitcoinj/core/Transaction.java +++ b/core/src/main/java/org/bitcoinj/core/Transaction.java @@ -1162,14 +1162,13 @@ public TransactionConfidence getConfidence(TxConfidenceTable table) { // Use the confidence from the table as that is all we have confidence = confidenceInTable; } else { - // Check the confidence in the Context confidence table is the same object - if (System.identityHashCode(confidence) != System.identityHashCode(confidenceInTable)) { - log.debug("Confidence in tx has identity {} but the one in the confidence table is {}", System.identityHashCode(confidence), System.identityHashCode(confidenceInTable)); - - if (ConfidenceType.UNKNOWN.equals(confidenceInTable.getConfidenceType())) { - // Do not override an extant confidence if the confidenceType is Unknown - log.debug("Not overriding confidence as confidenceType is Unknown"); - } else { + // Do not override local copy with a null Confidence in the TxConfidenceTable + if (confidenceInTable != null) { + // Check the confidence in the Context confidence table is the same object + // If Confidence objects are the same then do nothing + if (System.identityHashCode(confidence) != System.identityHashCode(confidenceInTable)) { + log.debug("Confidence in tx has identity {} but the one in the confidence table is {}", System.identityHashCode(confidence), System.identityHashCode(confidenceInTable)); + log.debug("Using the one in the confidence table"); confidence = confidenceInTable; }