Skip to content

Commit 92b277d

Browse files
fix: add lock to manual notify confidence functions
1 parent 2984148 commit 92b277d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

core/src/main/java/org/bitcoinj/wallet/Wallet.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,7 +2708,7 @@ public void updateTransactionDepth() {
27082708
// included once again. We could have a separate was-in-chain-and-now-isn't confidence type
27092709
// but this way is backwards compatible with existing software, and the new state probably
27102710
// wouldn't mean anything different to just remembering peers anyway.
2711-
confidence.setDepthInBlocks(lastBlockSeenHeight - confidence.getAppearedAtChainHeight());
2711+
confidence.setDepthInBlocks(lastBlockSeenHeight - confidence.getAppearedAtChainHeight() + 1);
27122712
if (confidence.getDepthInBlocks() > context.getEventHorizon())
27132713
confidence.clearBroadcastBy();
27142714
confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH);
@@ -6584,10 +6584,20 @@ public void unlockOutput(TransactionOutPoint outPoint) {
65846584
}
65856585

65866586
public void addManualNotifyConfidenceChangeTransaction(Transaction tx) {
6587-
manualConfidenceChangeTransactions.add(tx);
6587+
lock.lock();
6588+
try {
6589+
manualConfidenceChangeTransactions.add(tx);
6590+
} finally {
6591+
lock.unlock();
6592+
}
65886593
}
65896594

65906595
public void removeManualNotifyConfidenceChangeTransaction(Transaction tx) {
6591-
manualConfidenceChangeTransactions.remove(tx);
6596+
lock.lock();
6597+
try {
6598+
manualConfidenceChangeTransactions.remove(tx);
6599+
} finally {
6600+
lock.unlock();
6601+
}
65926602
}
65936603
}

0 commit comments

Comments
 (0)