mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-01 21:17:13 +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();
|
DeterministicKey parent = detkey.getParent();
|
||||||
if (parent == null) continue;
|
if (parent == null) continue;
|
||||||
if (detkey.getPath().size() <= treeSize) continue;
|
if (detkey.getPath().size() <= treeSize) continue;
|
||||||
if (parent.equals(internalKey) && detkey.getChildNumber().i() > issuedInternalKeys) continue;
|
if (parent.equals(internalKey) && detkey.getChildNumber().i() >= issuedInternalKeys) continue;
|
||||||
if (parent.equals(externalKey) && detkey.getChildNumber().i() > issuedExternalKeys) continue;
|
if (parent.equals(externalKey) && detkey.getChildNumber().i() >= issuedExternalKeys) continue;
|
||||||
issuedKeys.add(detkey);
|
issuedKeys.add(detkey);
|
||||||
}
|
}
|
||||||
return issuedKeys;
|
return issuedKeys;
|
||||||
|
|||||||
@@ -72,6 +72,14 @@ public class DeterministicKeyChainTest {
|
|||||||
key3.sign(Sha256Hash.ZERO_HASH);
|
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
|
@Test
|
||||||
public void signMessage() throws Exception {
|
public void signMessage() throws Exception {
|
||||||
ECKey key = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
ECKey key = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||||
|
|||||||
Reference in New Issue
Block a user