3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-11 17:55:53 +00:00

Throw when trying to set creation time of a DeterministicKey that is a leaf in the hierarchy. It would be needlessly stored, but unreadable.

This commit is contained in:
Andreas Schildbach 2014-12-11 21:22:54 +01:00
parent eb24bafdbc
commit b2526f0b4d
2 changed files with 12 additions and 1 deletions

View File

@ -441,6 +441,18 @@ public class DeterministicKey extends ECKey {
return super.getCreationTimeSeconds();
}
/**
* The creation time of a deterministic key is equal to that of its parent, unless this key is the root of a tree.
* Thus, setting the creation time on a leaf is forbidden.
*/
@Override
public void setCreationTimeSeconds(long newCreationTimeSeconds) {
if (parent != null)
throw new IllegalStateException("Creation time can only be set on root keys.");
else
super.setCreationTimeSeconds(newCreationTimeSeconds);
}
/**
* Verifies equality of all fields but NOT the parent pointer (thus the same key derived in two separate heirarchy
* objects will equal each other.

View File

@ -199,7 +199,6 @@ public class ChildKeyDerivationTest {
// Creation time can't survive the xpub serialization format unfortunately.
key1.setCreationTimeSeconds(0);
key2.setCreationTimeSeconds(0);
NetworkParameters params = MainNetParams.get();
{