From 2e1012da8b1135ba1569a6bc4c8b2fc856af17c8 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 25 Jun 2020 16:44:25 +0200 Subject: [PATCH] fix off by one bug --- .../java/com/sparrowwallet/drongo/wallet/Wallet.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 4d5e2be..d65ab46 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -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) {