mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +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:
@@ -441,6 +441,18 @@ public class DeterministicKey extends ECKey {
|
|||||||
return super.getCreationTimeSeconds();
|
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
|
* Verifies equality of all fields but NOT the parent pointer (thus the same key derived in two separate heirarchy
|
||||||
* objects will equal each other.
|
* objects will equal each other.
|
||||||
|
@@ -199,7 +199,6 @@ public class ChildKeyDerivationTest {
|
|||||||
|
|
||||||
// Creation time can't survive the xpub serialization format unfortunately.
|
// Creation time can't survive the xpub serialization format unfortunately.
|
||||||
key1.setCreationTimeSeconds(0);
|
key1.setCreationTimeSeconds(0);
|
||||||
key2.setCreationTimeSeconds(0);
|
|
||||||
NetworkParameters params = MainNetParams.get();
|
NetworkParameters params = MainNetParams.get();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user