mirror of
https://github.com/Qortal/qortal.git
synced 2025-05-07 10:17:51 +00:00
Fix for missing transactions in getWalletTransactions() response
The previous criteria was to stop searching for more leaf keys as soon as we found a batch of keys with no transactions, but it seems that there are occasions when subsequent batches do actually contain transactions. The solution/workaround is to require 5 consecutive empty batches before giving up. There may be ways to improve this further by copying approaches from other BIP32 implementations, but this is a quick fix that should solve the problem for now.
This commit is contained in:
parent
67f856c997
commit
3073388403
@ -351,6 +351,10 @@ public abstract class Bitcoiny implements ForeignBlockchain {
|
|||||||
Set<BitcoinyTransaction> walletTransactions = new HashSet<>();
|
Set<BitcoinyTransaction> walletTransactions = new HashSet<>();
|
||||||
Set<String> keySet = new HashSet<>();
|
Set<String> keySet = new HashSet<>();
|
||||||
|
|
||||||
|
// Set the number of consecutive empty batches required before giving up
|
||||||
|
final int numberOfAdditionalBatchesToSearch = 5;
|
||||||
|
|
||||||
|
int unusedCounter = 0;
|
||||||
int ki = 0;
|
int ki = 0;
|
||||||
do {
|
do {
|
||||||
boolean areAllKeysUnused = true;
|
boolean areAllKeysUnused = true;
|
||||||
@ -374,9 +378,19 @@ public abstract class Bitcoiny implements ForeignBlockchain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (areAllKeysUnused)
|
if (areAllKeysUnused) {
|
||||||
// No transactions for this batch of keys so assume we're done searching.
|
// No transactions
|
||||||
|
if (unusedCounter >= numberOfAdditionalBatchesToSearch) {
|
||||||
|
// ... and we've hit our search limit
|
||||||
break;
|
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
|
// Generate some more keys
|
||||||
keys.addAll(generateMoreKeys(keyChain));
|
keys.addAll(generateMoreKeys(keyChain));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user