diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index f21dd35..7189856 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -13,7 +13,7 @@ import java.util.*; import java.util.stream.Collectors; public class Wallet { - private static final int DEFAULT_LOOKAHEAD = 20; + public static final int DEFAULT_LOOKAHEAD = 20; private String name; private PolicyType policyType; @@ -75,10 +75,6 @@ public class Wallet { return keystores; } - public void setKeystores(List keystores) { - this.keystores = keystores; - } - private Set getPurposeNodes() { return purposeNodes; } @@ -113,7 +109,7 @@ public class Wallet { int lookAhead = DEFAULT_LOOKAHEAD; Integer highestUsed = node.getHighestUsedIndex(); if(highestUsed != null) { - lookAhead = Math.max(highestUsed + lookAhead/2, lookAhead); + lookAhead = highestUsed + lookAhead; } return lookAhead; diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java index f388c52..19cdd92 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java @@ -157,7 +157,19 @@ public class WalletNode implements Comparable { @Override public int compareTo(WalletNode node) { - return getIndex() - node.getIndex(); + if(getDerivation().size() != node.getDerivation().size()) { + return getDerivation().size() - node.getDerivation().size(); + } + + for(int i = 0; i < getDerivation().size(); i++) { + ChildNumber thisChild = getDerivation().get(i); + ChildNumber nodeChild = node.getDerivation().get(i); + if(thisChild.num() != nodeChild.num()) { + return thisChild.num() - nodeChild.num(); + } + } + + return 0; } public void clearHistory() {