mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 09:50:32 +01:00
EncryptableItem: rename creationTime()
method from getCreationTime()
This commit is contained in:
parent
45f87d8339
commit
b309308076
@ -308,7 +308,7 @@ public class DeterministicKey extends ECKey {
|
|||||||
EncryptedData encryptedPrivateKey = keyCrypter.encrypt(privKeyBytes, aesKey);
|
EncryptedData encryptedPrivateKey = keyCrypter.encrypt(privKeyBytes, aesKey);
|
||||||
DeterministicKey key = new DeterministicKey(childNumberPath, chainCode, keyCrypter, pub, encryptedPrivateKey, newParent);
|
DeterministicKey key = new DeterministicKey(childNumberPath, chainCode, keyCrypter, pub, encryptedPrivateKey, newParent);
|
||||||
if (newParent == null) {
|
if (newParent == null) {
|
||||||
Optional<Instant> creationTime = getCreationTime();
|
Optional<Instant> creationTime = this.creationTime();
|
||||||
if (creationTime.isPresent())
|
if (creationTime.isPresent())
|
||||||
key.setCreationTime(creationTime.get());
|
key.setCreationTime(creationTime.get());
|
||||||
else
|
else
|
||||||
@ -388,7 +388,7 @@ public class DeterministicKey extends ECKey {
|
|||||||
if (!Arrays.equals(key.getPubKey(), getPubKey()))
|
if (!Arrays.equals(key.getPubKey(), getPubKey()))
|
||||||
throw new KeyCrypterException.PublicPrivateMismatch("Provided AES key is wrong");
|
throw new KeyCrypterException.PublicPrivateMismatch("Provided AES key is wrong");
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
Optional<Instant> creationTime = getCreationTime();
|
Optional<Instant> creationTime = this.creationTime();
|
||||||
if (creationTime.isPresent())
|
if (creationTime.isPresent())
|
||||||
key.setCreationTime(creationTime.get());
|
key.setCreationTime(creationTime.get());
|
||||||
else
|
else
|
||||||
@ -705,14 +705,14 @@ public class DeterministicKey extends ECKey {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The creation time of a deterministic key is equal to that of its parent, unless this key is the root of a tree
|
* The creation time of a deterministic key is equal to that of its parent, unless this key is the root of a tree
|
||||||
* in which case the time is stored alongside the key as per normal, see {@link ECKey#getCreationTime()}.
|
* in which case the time is stored alongside the key as per normal, see {@link ECKey#creationTime()}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Optional<Instant> getCreationTime() {
|
public Optional<Instant> creationTime() {
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
return parent.getCreationTime();
|
return parent.creationTime();
|
||||||
else
|
else
|
||||||
return super.getCreationTime();
|
return super.creationTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -776,7 +776,7 @@ public class DeterministicKey extends ECKey {
|
|||||||
helper.add("pub", ByteUtils.formatHex(pub.getEncoded()));
|
helper.add("pub", ByteUtils.formatHex(pub.getEncoded()));
|
||||||
helper.add("chainCode", ByteUtils.formatHex(chainCode));
|
helper.add("chainCode", ByteUtils.formatHex(chainCode));
|
||||||
helper.add("path", getPathAsString());
|
helper.add("path", getPathAsString());
|
||||||
Optional<Instant> creationTime = getCreationTime();
|
Optional<Instant> creationTime = this.creationTime();
|
||||||
if (!creationTime.isPresent())
|
if (!creationTime.isPresent())
|
||||||
helper.add("creationTimeSeconds", "unknown");
|
helper.add("creationTimeSeconds", "unknown");
|
||||||
else if (parent != null)
|
else if (parent != null)
|
||||||
|
@ -122,7 +122,7 @@ public class ECKey implements EncryptableItem {
|
|||||||
private static final Comparator<byte[]> LEXICOGRAPHICAL_COMPARATOR = ByteUtils.arrayUnsignedComparator();
|
private static final Comparator<byte[]> LEXICOGRAPHICAL_COMPARATOR = ByteUtils.arrayUnsignedComparator();
|
||||||
|
|
||||||
/** Sorts oldest keys first, newest last. */
|
/** Sorts oldest keys first, newest last. */
|
||||||
public static final Comparator<ECKey> AGE_COMPARATOR = Comparator.comparing(ecKey -> ecKey.getCreationTime().orElse(Instant.EPOCH));
|
public static final Comparator<ECKey> AGE_COMPARATOR = Comparator.comparing(ecKey -> ecKey.creationTime().orElse(Instant.EPOCH));
|
||||||
|
|
||||||
/** Compares by extracting pub key as a {@code byte[]} and using a lexicographic comparator */
|
/** Compares by extracting pub key as a {@code byte[]} and using a lexicographic comparator */
|
||||||
public static final Comparator<ECKey> PUBKEY_COMPARATOR = Comparator.comparing(ECKey::getPubKey, LEXICOGRAPHICAL_COMPARATOR);
|
public static final Comparator<ECKey> PUBKEY_COMPARATOR = Comparator.comparing(ECKey::getPubKey, LEXICOGRAPHICAL_COMPARATOR);
|
||||||
@ -1080,7 +1080,7 @@ public class ECKey implements EncryptableItem {
|
|||||||
* that data.
|
* that data.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Optional<Instant> getCreationTime() {
|
public Optional<Instant> creationTime() {
|
||||||
return Optional.ofNullable(creationTime);
|
return Optional.ofNullable(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ public interface EncryptableItem {
|
|||||||
Protos.Wallet.EncryptionType getEncryptionType();
|
Protos.Wallet.EncryptionType getEncryptionType();
|
||||||
|
|
||||||
/** Returns the time at which this encryptable item was first created/derived, or empty of unknown. */
|
/** Returns the time at which this encryptable item was first created/derived, or empty of unknown. */
|
||||||
Optional<Instant> getCreationTime();
|
Optional<Instant> creationTime();
|
||||||
|
|
||||||
/** @deprecated use {@link #getCreationTime()} */
|
/** @deprecated use {@link #creationTime()} */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default long getCreationTimeSeconds() {
|
default long getCreationTimeSeconds() {
|
||||||
Optional<Instant> creationTime = getCreationTime();
|
Optional<Instant> creationTime = creationTime();
|
||||||
return creationTime.isPresent() ? creationTime.get().getEpochSecond() : 0;
|
return creationTime.isPresent() ? creationTime.get().getEpochSecond() : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,13 +339,13 @@ public class WalletAppKit extends AbstractIdleService {
|
|||||||
// Initialize the chain file with a checkpoint to speed up first-run sync.
|
// Initialize the chain file with a checkpoint to speed up first-run sync.
|
||||||
Instant time;
|
Instant time;
|
||||||
if (restoreFromSeed != null) {
|
if (restoreFromSeed != null) {
|
||||||
time = restoreFromSeed.getCreationTime().orElse(Instant.EPOCH);
|
time = restoreFromSeed.creationTime().orElse(Instant.EPOCH);
|
||||||
if (chainFileExists) {
|
if (chainFileExists) {
|
||||||
log.info("Clearing the chain file in preparation for restore.");
|
log.info("Clearing the chain file in preparation for restore.");
|
||||||
vStore.clear();
|
vStore.clear();
|
||||||
}
|
}
|
||||||
} else if (restoreFromKey != null) {
|
} else if (restoreFromKey != null) {
|
||||||
time = restoreFromKey.getCreationTime().orElse(Instant.EPOCH);
|
time = restoreFromKey.creationTime().orElse(Instant.EPOCH);
|
||||||
if (chainFileExists) {
|
if (chainFileExists) {
|
||||||
log.info("Clearing the chain file in preparation for restore.");
|
log.info("Clearing the chain file in preparation for restore.");
|
||||||
vStore.clear();
|
vStore.clear();
|
||||||
|
@ -295,7 +295,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
return hashToKeys.values().stream()
|
return hashToKeys.values().stream()
|
||||||
.map(key -> key.getCreationTime().orElse(Instant.EPOCH))
|
.map(key -> key.creationTime().orElse(Instant.EPOCH))
|
||||||
.min(Instant::compareTo)
|
.min(Instant::compareTo)
|
||||||
.orElse(Instant.MAX);
|
.orElse(Instant.MAX);
|
||||||
} finally {
|
} finally {
|
||||||
@ -348,7 +348,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
|||||||
|
|
||||||
/*package*/ static Protos.Key.Builder serializeEncryptableItem(EncryptableItem item) {
|
/*package*/ static Protos.Key.Builder serializeEncryptableItem(EncryptableItem item) {
|
||||||
Protos.Key.Builder proto = Protos.Key.newBuilder();
|
Protos.Key.Builder proto = Protos.Key.newBuilder();
|
||||||
item.getCreationTime().ifPresent(creationTime -> proto.setCreationTimestamp(creationTime.toEpochMilli()));
|
item.creationTime().ifPresent(creationTime -> proto.setCreationTimestamp(creationTime.toEpochMilli()));
|
||||||
if (item.isEncrypted() && item.getEncryptedData() != null) {
|
if (item.isEncrypted() && item.getEncryptedData() != null) {
|
||||||
// The encrypted data can be missing for an "encrypted" key in the case of a deterministic wallet for
|
// The encrypted data can be missing for an "encrypted" key in the case of a deterministic wallet for
|
||||||
// which the leaf keys chain to an encrypted parent and rederive their private keys on the fly. In that
|
// which the leaf keys chain to an encrypted parent and rederive their private keys on the fly. In that
|
||||||
@ -629,9 +629,9 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
|||||||
try {
|
try {
|
||||||
ECKey oldest = null;
|
ECKey oldest = null;
|
||||||
for (ECKey key : hashToKeys.values()) {
|
for (ECKey key : hashToKeys.values()) {
|
||||||
Instant keyTime = key.getCreationTime().orElse(Instant.EPOCH);
|
Instant keyTime = key.creationTime().orElse(Instant.EPOCH);
|
||||||
if (keyTime.isAfter(time)) {
|
if (keyTime.isAfter(time)) {
|
||||||
if (oldest == null || oldest.getCreationTime().orElse(Instant.EPOCH).isAfter(keyTime))
|
if (oldest == null || oldest.creationTime().orElse(Instant.EPOCH).isAfter(keyTime))
|
||||||
oldest = key;
|
oldest = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -654,7 +654,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
|||||||
try {
|
try {
|
||||||
List<ECKey> results = new LinkedList<>();
|
List<ECKey> results = new LinkedList<>();
|
||||||
for (ECKey key : hashToKeys.values()) {
|
for (ECKey key : hashToKeys.values()) {
|
||||||
Instant keyTime = key.getCreationTime().orElse(Instant.EPOCH);
|
Instant keyTime = key.creationTime().orElse(Instant.EPOCH);
|
||||||
if (keyTime.isBefore(time)) {
|
if (keyTime.isBefore(time)) {
|
||||||
results.add(key);
|
results.add(key);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
|||||||
basicKeyChain = new BasicKeyChain(crypter);
|
basicKeyChain = new BasicKeyChain(crypter);
|
||||||
if (!seed.isEncrypted()) {
|
if (!seed.isEncrypted()) {
|
||||||
rootKey = HDKeyDerivation.createMasterPrivateKey(Objects.requireNonNull(seed.getSeedBytes()));
|
rootKey = HDKeyDerivation.createMasterPrivateKey(Objects.requireNonNull(seed.getSeedBytes()));
|
||||||
Optional<Instant> creationTime = seed.getCreationTime();
|
Optional<Instant> creationTime = seed.creationTime();
|
||||||
if (creationTime.isPresent())
|
if (creationTime.isPresent())
|
||||||
rootKey.setCreationTime(creationTime.get());
|
rootKey.setCreationTime(creationTime.get());
|
||||||
else
|
else
|
||||||
@ -726,8 +726,8 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
|||||||
@Override
|
@Override
|
||||||
public Instant earliestKeyCreationTime() {
|
public Instant earliestKeyCreationTime() {
|
||||||
return (seed != null ?
|
return (seed != null ?
|
||||||
seed.getCreationTime() :
|
seed.creationTime() :
|
||||||
getWatchingKey().getCreationTime()
|
getWatchingKey().creationTime()
|
||||||
).orElse(Instant.EPOCH);
|
).orElse(Instant.EPOCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1452,7 +1452,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
|||||||
builder.append("Seed is encrypted\n");
|
builder.append("Seed is encrypted\n");
|
||||||
}
|
}
|
||||||
builder.append("Seed birthday: ");
|
builder.append("Seed birthday: ");
|
||||||
Optional<Instant> seedCreationTime = seed.getCreationTime();
|
Optional<Instant> seedCreationTime = seed.creationTime();
|
||||||
if (seedCreationTime.isPresent())
|
if (seedCreationTime.isPresent())
|
||||||
builder.append(seedCreationTime.get().getEpochSecond()).append(" [")
|
builder.append(seedCreationTime.get().getEpochSecond()).append(" [")
|
||||||
.append(TimeUtils.dateTimeFormat(seedCreationTime.get())).append("]");
|
.append(TimeUtils.dateTimeFormat(seedCreationTime.get())).append("]");
|
||||||
@ -1461,7 +1461,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
|||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
} else {
|
} else {
|
||||||
builder.append("Key birthday: ");
|
builder.append("Key birthday: ");
|
||||||
Optional<Instant> watchingKeyCreationTime = watchingKey.getCreationTime();
|
Optional<Instant> watchingKeyCreationTime = watchingKey.creationTime();
|
||||||
if (watchingKeyCreationTime.isPresent())
|
if (watchingKeyCreationTime.isPresent())
|
||||||
builder.append(watchingKeyCreationTime.get().getEpochSecond()).append(" [")
|
builder.append(watchingKeyCreationTime.get().getEpochSecond()).append(" [")
|
||||||
.append(TimeUtils.dateTimeFormat(watchingKeyCreationTime.get())).append("]");
|
.append(TimeUtils.dateTimeFormat(watchingKeyCreationTime.get())).append("]");
|
||||||
|
@ -268,7 +268,7 @@ public class DeterministicSeed implements EncryptableItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Instant> getCreationTime() {
|
public Optional<Instant> creationTime() {
|
||||||
return Optional.ofNullable(creationTime);
|
return Optional.ofNullable(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class KeyTimeCoinSelector implements CoinSelector {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Objects.requireNonNull(controllingKey, "Coin selector given output as candidate for which we lack the key");
|
Objects.requireNonNull(controllingKey, "Coin selector given output as candidate for which we lack the key");
|
||||||
if (controllingKey.getCreationTime().orElse(Instant.EPOCH).compareTo(time) >= 0) continue;
|
if (controllingKey.creationTime().orElse(Instant.EPOCH).compareTo(time) >= 0) continue;
|
||||||
// It's older than the cutoff time so select.
|
// It's older than the cutoff time so select.
|
||||||
gathered.push(output);
|
gathered.push(output);
|
||||||
if (gathered.size() >= MAX_SIMULTANEOUS_INPUTS) {
|
if (gathered.size() >= MAX_SIMULTANEOUS_INPUTS) {
|
||||||
|
@ -481,7 +481,7 @@ public class Wallet extends BaseTaggableObject
|
|||||||
ScriptType outputScriptType, ChildNumber accountNumber) {
|
ScriptType outputScriptType, ChildNumber accountNumber) {
|
||||||
DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(masterKey, accountNumber);
|
DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(masterKey, accountNumber);
|
||||||
accountKey = accountKey.dropParent();
|
accountKey = accountKey.dropParent();
|
||||||
Optional<Instant> creationTime = masterKey.getCreationTime();
|
Optional<Instant> creationTime = masterKey.creationTime();
|
||||||
if (creationTime.isPresent())
|
if (creationTime.isPresent())
|
||||||
accountKey.setCreationTime(creationTime.get());
|
accountKey.setCreationTime(creationTime.get());
|
||||||
else
|
else
|
||||||
@ -3620,7 +3620,7 @@ public class Wallet extends BaseTaggableObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the earliest creation time of keys or watched scripts in this wallet, ie the min
|
* Returns the earliest creation time of keys or watched scripts in this wallet, ie the min
|
||||||
* of {@link ECKey#getCreationTime()}. This can return {@link Instant#EPOCH} if at least one key does
|
* of {@link ECKey#creationTime()}. This can return {@link Instant#EPOCH} if at least one key does
|
||||||
* not have that data (e.g. is an imported key with unknown timestamp). <p>
|
* not have that data (e.g. is an imported key with unknown timestamp). <p>
|
||||||
*
|
*
|
||||||
* This method is most often used in conjunction with {@link PeerGroup#setFastCatchupTime(Instant)} in order to
|
* This method is most often used in conjunction with {@link PeerGroup#setFastCatchupTime(Instant)} in order to
|
||||||
@ -5435,7 +5435,7 @@ public class Wallet extends BaseTaggableObject
|
|||||||
/** Returns whether the keys creation time is before the key rotation time, if one was set. */
|
/** Returns whether the keys creation time is before the key rotation time, if one was set. */
|
||||||
public boolean isKeyRotating(ECKey key) {
|
public boolean isKeyRotating(ECKey key) {
|
||||||
Instant keyRotationTime = vKeyRotationTime;
|
Instant keyRotationTime = vKeyRotationTime;
|
||||||
return keyRotationTime != null && key.getCreationTime().orElse(Instant.EPOCH).isBefore(keyRotationTime);
|
return keyRotationTime != null && key.creationTime().orElse(Instant.EPOCH).isBefore(keyRotationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -340,12 +340,12 @@ public class ECKeyTest {
|
|||||||
public void testUnencryptedCreate() {
|
public void testUnencryptedCreate() {
|
||||||
TimeUtils.setMockClock();
|
TimeUtils.setMockClock();
|
||||||
ECKey key = new ECKey();
|
ECKey key = new ECKey();
|
||||||
Optional<Instant> time = key.getCreationTime();
|
Optional<Instant> time = key.creationTime();
|
||||||
assertTrue(time.isPresent());
|
assertTrue(time.isPresent());
|
||||||
assertTrue(!key.isEncrypted());
|
assertTrue(!key.isEncrypted());
|
||||||
byte[] originalPrivateKeyBytes = key.getPrivKeyBytes();
|
byte[] originalPrivateKeyBytes = key.getPrivKeyBytes();
|
||||||
ECKey encryptedKey = key.encrypt(keyCrypter, keyCrypter.deriveKey(PASSWORD1));
|
ECKey encryptedKey = key.encrypt(keyCrypter, keyCrypter.deriveKey(PASSWORD1));
|
||||||
assertEquals(time, encryptedKey.getCreationTime());
|
assertEquals(time, encryptedKey.creationTime());
|
||||||
assertTrue(encryptedKey.isEncrypted());
|
assertTrue(encryptedKey.isEncrypted());
|
||||||
assertNull(encryptedKey.getSecretBytes());
|
assertNull(encryptedKey.getSecretBytes());
|
||||||
key = encryptedKey.decrypt(keyCrypter.deriveKey(PASSWORD1));
|
key = encryptedKey.decrypt(keyCrypter.deriveKey(PASSWORD1));
|
||||||
|
@ -125,7 +125,7 @@ public class WalletProtobufSerializerTest {
|
|||||||
ECKey foundKey = wallet1.findKeyFromPubKeyHash(myKey.getPubKeyHash(), null);
|
ECKey foundKey = wallet1.findKeyFromPubKeyHash(myKey.getPubKeyHash(), null);
|
||||||
assertArrayEquals(myKey.getPubKey(), foundKey.getPubKey());
|
assertArrayEquals(myKey.getPubKey(), foundKey.getPubKey());
|
||||||
assertArrayEquals(myKey.getPrivKeyBytes(), foundKey.getPrivKeyBytes());
|
assertArrayEquals(myKey.getPrivKeyBytes(), foundKey.getPrivKeyBytes());
|
||||||
assertEquals(myKey.getCreationTime(), foundKey.getCreationTime());
|
assertEquals(myKey.creationTime(), foundKey.creationTime());
|
||||||
assertEquals(mScriptCreationTime.truncatedTo(ChronoUnit.MILLIS),
|
assertEquals(mScriptCreationTime.truncatedTo(ChronoUnit.MILLIS),
|
||||||
wallet1.getWatchedScripts().get(0).getCreationTime().get());
|
wallet1.getWatchedScripts().get(0).getCreationTime().get());
|
||||||
assertEquals(1, wallet1.getWatchedScripts().size());
|
assertEquals(1, wallet1.getWatchedScripts().size());
|
||||||
@ -343,7 +343,7 @@ public class WalletProtobufSerializerTest {
|
|||||||
ECKey foundKey = wallet1.findKeyFromPubKeyHash(myKey.getPubKeyHash(), null);
|
ECKey foundKey = wallet1.findKeyFromPubKeyHash(myKey.getPubKeyHash(), null);
|
||||||
assertArrayEquals(myKey.getPubKey(), foundKey.getPubKey());
|
assertArrayEquals(myKey.getPubKey(), foundKey.getPubKey());
|
||||||
assertArrayEquals(myKey.getPrivKeyBytes(), foundKey.getPrivKeyBytes());
|
assertArrayEquals(myKey.getPrivKeyBytes(), foundKey.getPrivKeyBytes());
|
||||||
assertEquals(myKey.getCreationTime(), foundKey.getCreationTime());
|
assertEquals(myKey.creationTime(), foundKey.creationTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -354,9 +354,9 @@ public class WalletProtobufSerializerTest {
|
|||||||
Wallet wallet2 = roundTrip(wallet);
|
Wallet wallet2 = roundTrip(wallet);
|
||||||
Wallet wallet3 = roundTrip(wallet2);
|
Wallet wallet3 = roundTrip(wallet2);
|
||||||
assertEquals(xpub, wallet.getWatchingKey().serializePubB58(TESTNET.network()));
|
assertEquals(xpub, wallet.getWatchingKey().serializePubB58(TESTNET.network()));
|
||||||
assertEquals(creationTime, wallet.getWatchingKey().getCreationTime().get());
|
assertEquals(creationTime, wallet.getWatchingKey().creationTime().get());
|
||||||
assertEquals(creationTime, wallet2.getWatchingKey().getCreationTime().get());
|
assertEquals(creationTime, wallet2.getWatchingKey().creationTime().get());
|
||||||
assertEquals(creationTime, wallet3.getWatchingKey().getCreationTime().get());
|
assertEquals(creationTime, wallet3.getWatchingKey().creationTime().get());
|
||||||
assertEquals(creationTime, wallet.earliestKeyCreationTime());
|
assertEquals(creationTime, wallet.earliestKeyCreationTime());
|
||||||
assertEquals(creationTime, wallet2.earliestKeyCreationTime());
|
assertEquals(creationTime, wallet2.earliestKeyCreationTime());
|
||||||
assertEquals(creationTime, wallet3.earliestKeyCreationTime());
|
assertEquals(creationTime, wallet3.earliestKeyCreationTime());
|
||||||
|
@ -656,7 +656,7 @@ public class DeterministicKeyChainTest {
|
|||||||
//Simulate Wallet.fromMasterKey(params, coinLevelKey, 0)
|
//Simulate Wallet.fromMasterKey(params, coinLevelKey, 0)
|
||||||
DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(coinLevelKey, new ChildNumber(0, true));
|
DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(coinLevelKey, new ChildNumber(0, true));
|
||||||
accountKey = accountKey.dropParent();
|
accountKey = accountKey.dropParent();
|
||||||
accountKey.setCreationTime(watchingKey.getCreationTime().get());
|
accountKey.setCreationTime(watchingKey.creationTime().get());
|
||||||
KeyChainGroup group = KeyChainGroup.builder(NetworkParameters.of(network)).addChain(DeterministicKeyChain.builder().spend(accountKey)
|
KeyChainGroup group = KeyChainGroup.builder(NetworkParameters.of(network)).addChain(DeterministicKeyChain.builder().spend(accountKey)
|
||||||
.outputScriptType(bip44chain.getOutputScriptType()).build()).build();
|
.outputScriptType(bip44chain.getOutputScriptType()).build()).build();
|
||||||
DeterministicKeyChain fromMasterKeyChain = group.getActiveKeyChain();
|
DeterministicKeyChain fromMasterKeyChain = group.getActiveKeyChain();
|
||||||
|
@ -42,7 +42,7 @@ public class BackupToMnemonicSeed {
|
|||||||
DeterministicSeed seed = wallet.getKeyChainSeed();
|
DeterministicSeed seed = wallet.getKeyChainSeed();
|
||||||
System.out.println("seed: " + seed.toString());
|
System.out.println("seed: " + seed.toString());
|
||||||
|
|
||||||
System.out.println("creation time: " + seed.getCreationTime().get().getEpochSecond());
|
System.out.println("creation time: " + seed.creationTime().get().getEpochSecond());
|
||||||
System.out.println("mnemonicCode: " + InternalUtils.SPACE_JOINER.join(seed.getMnemonicCode()));
|
System.out.println("mnemonicCode: " + InternalUtils.SPACE_JOINER.join(seed.getMnemonicCode()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class WalletLoadTest {
|
|||||||
Context.propagate(new Context());
|
Context.propagate(new Context());
|
||||||
Wallet wallet = Wallet.loadFromFile(walletFile);
|
Wallet wallet = Wallet.loadFromFile(walletFile);
|
||||||
|
|
||||||
Instant creation = wallet.getKeyChainSeed().getCreationTime().get();
|
Instant creation = wallet.getKeyChainSeed().creationTime().get();
|
||||||
assertEquals(testWalletCreation, creation, "unexpected creation timestamp");
|
assertEquals(testWalletCreation, creation, "unexpected creation timestamp");
|
||||||
|
|
||||||
String mnemonic = wallet.getKeyChainSeed().getMnemonicString();
|
String mnemonic = wallet.getKeyChainSeed().getMnemonicString();
|
||||||
|
@ -88,7 +88,7 @@ public class WalletSettingsController implements OverlayController<WalletSetting
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the date picker to show the birthday of this wallet.
|
// Set the date picker to show the birthday of this wallet.
|
||||||
Instant creationTime = seed.getCreationTime().get();
|
Instant creationTime = seed.creationTime().get();
|
||||||
LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
|
LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||||
datePicker.setValue(origDate);
|
datePicker.setValue(origDate);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user