mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 18:00:39 +01:00
KeyChainGroup: rename earliestKeyCreationTime()
method from getEarliestKeyCreationTimeInstant()
This commit is contained in:
parent
5db4e1eadd
commit
a68f7f958c
@ -850,14 +850,14 @@ public class KeyChainGroup implements KeyBag {
|
||||
* {@link Instant#EPOCH} if at least one time is unknown,
|
||||
* {@link Instant#MAX} if no keys in this group
|
||||
*/
|
||||
public Instant getEarliestKeyCreationTimeInstant() {
|
||||
public Instant earliestKeyCreationTime() {
|
||||
return TimeUtils.earlier(basic.earliestKeyCreationTime(), getEarliestChainsCreationTime());
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #getEarliestKeyCreationTimeInstant()} */
|
||||
/** @deprecated use {@link #earliestKeyCreationTime()} */
|
||||
@Deprecated
|
||||
public long getEarliestKeyCreationTime() {
|
||||
Instant earliestKeyCreationTime = getEarliestKeyCreationTimeInstant();
|
||||
Instant earliestKeyCreationTime = earliestKeyCreationTime();
|
||||
return earliestKeyCreationTime.equals(Instant.MAX) ? Long.MAX_VALUE : earliestKeyCreationTime.getEpochSecond();
|
||||
}
|
||||
|
||||
|
@ -3638,7 +3638,7 @@ public class Wallet extends BaseTaggableObject
|
||||
public Instant earliestKeyCreationTime() {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
Instant earliestTime = keyChainGroup.getEarliestKeyCreationTimeInstant();
|
||||
Instant earliestTime = keyChainGroup.earliestKeyCreationTime();
|
||||
for (Script script : watchedScripts)
|
||||
earliestTime = TimeUtils.earlier(script.getCreationTime().orElse(Instant.EPOCH), earliestTime);
|
||||
return earliestTime;
|
||||
|
@ -262,7 +262,7 @@ public class KeyChainGroupTest {
|
||||
Instant now = TimeUtils.currentTime().truncatedTo(ChronoUnit.SECONDS);
|
||||
TimeUtils.setMockClock(now);
|
||||
ECKey a = group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
assertEquals(now, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(now, group.earliestKeyCreationTime());
|
||||
Instant yesterday = now.minus(1, ChronoUnit.DAYS);
|
||||
TimeUtils.setMockClock(yesterday);
|
||||
ECKey b = new ECKey();
|
||||
@ -274,9 +274,9 @@ public class KeyChainGroupTest {
|
||||
} catch (IllegalStateException e) {
|
||||
}
|
||||
if (withImported) {
|
||||
assertEquals(now, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(now, group.earliestKeyCreationTime());
|
||||
group.importKeys(b);
|
||||
assertEquals(yesterday, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(yesterday, group.earliestKeyCreationTime());
|
||||
}
|
||||
group.encrypt(KEY_CRYPTER, AES_KEY);
|
||||
assertTrue(group.isEncrypted());
|
||||
@ -286,9 +286,9 @@ public class KeyChainGroupTest {
|
||||
assertTrue(Objects.requireNonNull(ea).isEncrypted());
|
||||
if (withImported) {
|
||||
assertTrue(Objects.requireNonNull(group.findKeyFromPubKey(b.getPubKey())).isEncrypted());
|
||||
assertEquals(yesterday, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(yesterday, group.earliestKeyCreationTime());
|
||||
} else {
|
||||
assertEquals(now, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(now, group.earliestKeyCreationTime());
|
||||
}
|
||||
try {
|
||||
ea.sign(Sha256Hash.ZERO_HASH);
|
||||
@ -323,9 +323,9 @@ public class KeyChainGroupTest {
|
||||
assertFalse(Objects.requireNonNull(group.findKeyFromPubKey(a.getPubKey())).isEncrypted());
|
||||
if (withImported) {
|
||||
assertFalse(Objects.requireNonNull(group.findKeyFromPubKey(b.getPubKey())).isEncrypted());
|
||||
assertEquals(yesterday, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(yesterday, group.earliestKeyCreationTime());
|
||||
} else {
|
||||
assertEquals(now, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(now, group.earliestKeyCreationTime());
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,18 +408,18 @@ public class KeyChainGroupTest {
|
||||
public void earliestKeyTime() {
|
||||
Instant now = TimeUtils.currentTime().truncatedTo(ChronoUnit.SECONDS);
|
||||
TimeUtils.setMockClock(now);
|
||||
assertEquals(now, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(now, group.earliestKeyCreationTime());
|
||||
TimeUtils.rollMockClock(Duration.ofSeconds(10000));
|
||||
group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
TimeUtils.rollMockClock(Duration.ofSeconds(10000));
|
||||
group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
// Check that all keys are assumed to be created at the same instant the seed is.
|
||||
assertEquals(now, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(now, group.earliestKeyCreationTime());
|
||||
ECKey key = new ECKey();
|
||||
Instant yesterday = now.minus(1, ChronoUnit.DAYS);
|
||||
key.setCreationTime(yesterday);
|
||||
group.importKeys(key);
|
||||
assertEquals(yesterday, group.getEarliestKeyCreationTimeInstant());
|
||||
assertEquals(yesterday, group.earliestKeyCreationTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user