diff --git a/src/main/java/org/qortal/crosschain/Bitcoiny.java b/src/main/java/org/qortal/crosschain/Bitcoiny.java index 5aed404c0..d4693818a 100644 --- a/src/main/java/org/qortal/crosschain/Bitcoiny.java +++ b/src/main/java/org/qortal/crosschain/Bitcoiny.java @@ -351,6 +351,10 @@ public List getWalletTransactions(String key58) throws Foreig Set walletTransactions = new HashSet<>(); Set keySet = new HashSet<>(); + // Set the number of consecutive empty batches required before giving up + final int numberOfAdditionalBatchesToSearch = 5; + + int unusedCounter = 0; int ki = 0; do { boolean areAllKeysUnused = true; @@ -374,9 +378,19 @@ public List getWalletTransactions(String key58) throws Foreig } } - if (areAllKeysUnused) - // No transactions for this batch of keys so assume we're done searching. - break; + if (areAllKeysUnused) { + // No transactions + if (unusedCounter >= numberOfAdditionalBatchesToSearch) { + // ... and we've hit our search limit + break; + } + // We haven't hit our search limit yet so increment the counter and keep looking + unusedCounter++; + } + else { + // Some keys in this batch were used, so reset the counter + unusedCounter = 0; + } // Generate some more keys keys.addAll(generateMoreKeys(keyChain));