fix off by one bug

This commit is contained in:
Craig Raw 2020-06-25 16:44:25 +02:00
parent 66d4e11bf6
commit 2e1012da8b

View file

@ -101,18 +101,18 @@ public class Wallet {
purposeNode = optionalPurposeNode.get();
}
purposeNode.fillToIndex(getLookAhead(purposeNode));
purposeNode.fillToIndex(getLookAheadIndex(purposeNode));
return purposeNode;
}
public int getLookAhead(WalletNode node) {
int lookAhead = DEFAULT_LOOKAHEAD;
public int getLookAheadIndex(WalletNode node) {
int lookAheadIndex = DEFAULT_LOOKAHEAD - 1;
Integer highestUsed = node.getHighestUsedIndex();
if(highestUsed != null) {
lookAhead = highestUsed + lookAhead;
lookAheadIndex = highestUsed + DEFAULT_LOOKAHEAD;
}
return lookAhead;
return lookAheadIndex;
}
public WalletNode getFreshNode(KeyPurpose keyPurpose) {