mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
Fix off by one in DKC.getKeys(false). Resolves #253
This commit is contained in:
@@ -1186,8 +1186,8 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
DeterministicKey parent = detkey.getParent();
|
||||
if (parent == null) continue;
|
||||
if (detkey.getPath().size() <= treeSize) continue;
|
||||
if (parent.equals(internalKey) && detkey.getChildNumber().i() > issuedInternalKeys) continue;
|
||||
if (parent.equals(externalKey) && detkey.getChildNumber().i() > issuedExternalKeys) continue;
|
||||
if (parent.equals(internalKey) && detkey.getChildNumber().i() >= issuedInternalKeys) continue;
|
||||
if (parent.equals(externalKey) && detkey.getChildNumber().i() >= issuedExternalKeys) continue;
|
||||
issuedKeys.add(detkey);
|
||||
}
|
||||
return issuedKeys;
|
||||
|
@@ -72,6 +72,14 @@ public class DeterministicKeyChainTest {
|
||||
key3.sign(Sha256Hash.ZERO_HASH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getKeys() throws Exception {
|
||||
chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
chain.getKey(KeyChain.KeyPurpose.CHANGE);
|
||||
chain.maybeLookAhead();
|
||||
assertEquals(2, chain.getKeys(false).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signMessage() throws Exception {
|
||||
ECKey key = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
|
Reference in New Issue
Block a user