mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-11 17:58:01 +01: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:
parent
eb24bafdbc
commit
b2526f0b4d
2 changed files with 12 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue