diff --git a/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java b/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java index 317d66963eb..8f970b34ce2 100644 --- a/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java +++ b/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java @@ -368,8 +368,9 @@ public synchronized String toString() { * * @return the new depth */ - public synchronized int incrementDepthInBlocks() { - return ++this.depth; + public synchronized int incrementDepthInBlocks(int height) { + this.depth = height - getAppearedAtChainHeight() + 1; + return this.depth; } /** diff --git a/core/src/main/java/org/bitcoinj/wallet/Wallet.java b/core/src/main/java/org/bitcoinj/wallet/Wallet.java index 067c7cae226..aea2707921c 100644 --- a/core/src/main/java/org/bitcoinj/wallet/Wallet.java +++ b/core/src/main/java/org/bitcoinj/wallet/Wallet.java @@ -2127,7 +2127,7 @@ public void notifyNewBestBlock(StoredBlock block) throws VerificationException { // included once again. We could have a separate was-in-chain-and-now-isn't confidence type // but this way is backwards compatible with existing software, and the new state probably // wouldn't mean anything different to just remembering peers anyway. - if (confidence.incrementDepthInBlocks() > context.getEventHorizon()) + if (confidence.incrementDepthInBlocks(block.getHeight()) > context.getEventHorizon()) confidence.clearBroadcastBy(); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH); }