diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index c9ac410d..b36bd649 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -3648,6 +3648,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha */ @Override public int getBloomFilterElementCount() { + checkState(lock.isHeldByCurrentThread()); int size = keychain.getBloomFilterElementCount(); for (Transaction tx : getTransactions(false)) { for (TransactionOutput out : tx.getOutputs()) { @@ -3674,6 +3675,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha */ @Override public boolean isRequiringUpdateAllBloomFilter() { + checkState(lock.isHeldByCurrentThread()); return !watchedScripts.isEmpty(); } @@ -3698,23 +3700,17 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha */ @Override public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) { - BloomFilter filter; - lock.lock(); - try { - filter = keychain.getBloomFilter(size, falsePositiveRate, nTweak); - - for (Script script : watchedScripts) { - for (ScriptChunk chunk : script.getChunks()) { - // Only add long (at least 64 bit) data to the bloom filter. - // If any long constants become popular in scripts, we will need logic - // here to exclude them. - if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) { - filter.insert(chunk.data); - } + checkState(lock.isHeldByCurrentThread()); + BloomFilter filter = keychain.getBloomFilter(size, falsePositiveRate, nTweak); + for (Script script : watchedScripts) { + for (ScriptChunk chunk : script.getChunks()) { + // Only add long (at least 64 bit) data to the bloom filter. + // If any long constants become popular in scripts, we will need logic + // here to exclude them. + if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) { + filter.insert(chunk.data); } } - } finally { - lock.unlock(); } for (Transaction tx : getTransactions(false)) { for (int i = 0; i < tx.getOutputs().size(); i++) {