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 = optionalPurposeNode.get();
} }
purposeNode.fillToIndex(getLookAhead(purposeNode)); purposeNode.fillToIndex(getLookAheadIndex(purposeNode));
return purposeNode; return purposeNode;
} }
public int getLookAhead(WalletNode node) { public int getLookAheadIndex(WalletNode node) {
int lookAhead = DEFAULT_LOOKAHEAD; int lookAheadIndex = DEFAULT_LOOKAHEAD - 1;
Integer highestUsed = node.getHighestUsedIndex(); Integer highestUsed = node.getHighestUsedIndex();
if(highestUsed != null) { if(highestUsed != null) {
lookAhead = highestUsed + lookAhead; lookAheadIndex = highestUsed + DEFAULT_LOOKAHEAD;
} }
return lookAhead; return lookAheadIndex;
} }
public WalletNode getFreshNode(KeyPurpose keyPurpose) { public WalletNode getFreshNode(KeyPurpose keyPurpose) {