From d7a0e489de5f9a6db751cdbfe47e1cbc7f9b5cd5 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Fri, 26 Jan 2018 13:46:27 -0500 Subject: [PATCH] Fix issue: Transaction.updatedAt is not set at new block https://github.com/bisq-network/bitcoinj/issues/11 Cherry pick https://github.com/bisq-network/bitcoinj/commit/09679425a5a2b731ab2043e123c603d7d4b2f15b --- core/src/main/java/org/bitcoinj/core/Transaction.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/bitcoinj/core/Transaction.java b/core/src/main/java/org/bitcoinj/core/Transaction.java index 21154f2bace1..6fcb1dfa88ef 100644 --- a/core/src/main/java/org/bitcoinj/core/Transaction.java +++ b/core/src/main/java/org/bitcoinj/core/Transaction.java @@ -333,7 +333,14 @@ public boolean isPending() { */ public void setBlockAppearance(StoredBlock block, boolean bestChain, int relativityOffset) { long blockTime = block.getHeader().getTimeSeconds() * 1000; - if (bestChain && (updatedAt == null || updatedAt.getTime() == 0 || updatedAt.getTime() > blockTime)) { + + /* if (bestChain && (updatedAt == null || updatedAt.getTime() == 0 || updatedAt.getTime() > blockTime)) { + updatedAt = new Date(blockTime); + }*/ + // We removed for the checks to not overwrite updatedAt in cases for re-orgs. + // updatedAt is set by wallet.commit and thus the new block would never set the value. + // If there is a re-org the best block is called last as stated in the doc above so the values will be correct. + if (bestChain) { updatedAt = new Date(blockTime); }