Wallet: rename keyRotationTime() method from getKeyRotationTimeInstant()

This commit is contained in:
Andreas Schildbach 2023-03-18 10:58:43 +01:00
parent a68f7f958c
commit f583cea035
3 changed files with 5 additions and 5 deletions

View file

@ -3533,7 +3533,7 @@ public class Wallet extends BaseTaggableObject
builder.append("\nKeys:\n"); builder.append("\nKeys:\n");
builder.append("Earliest creation time: ").append(TimeUtils.dateTimeFormat(earliestKeyCreationTime())) builder.append("Earliest creation time: ").append(TimeUtils.dateTimeFormat(earliestKeyCreationTime()))
.append('\n'); .append('\n');
final Optional<Instant> keyRotationTime = getKeyRotationTimeInstant(); final Optional<Instant> keyRotationTime = keyRotationTime();
if (keyRotationTime.isPresent()) if (keyRotationTime.isPresent())
builder.append("Key rotation time: ").append(TimeUtils.dateTimeFormat(keyRotationTime.get())).append('\n'); builder.append("Key rotation time: ").append(TimeUtils.dateTimeFormat(keyRotationTime.get())).append('\n');
builder.append(keyChainGroup.toString(includeLookahead, includePrivateKeys, aesKey)); builder.append(keyChainGroup.toString(includeLookahead, includePrivateKeys, aesKey));
@ -5418,11 +5418,11 @@ public class Wallet extends BaseTaggableObject
* Returns the key rotation time, or empty if unconfigured. See {@link #setKeyRotationTime(Instant)} for a description * Returns the key rotation time, or empty if unconfigured. See {@link #setKeyRotationTime(Instant)} for a description
* of the field. * of the field.
*/ */
public Optional<Instant> getKeyRotationTimeInstant() { public Optional<Instant> keyRotationTime() {
return Optional.ofNullable(vKeyRotationTime); return Optional.ofNullable(vKeyRotationTime);
} }
/** @deprecated use {@link #getKeyRotationTimeInstant()} */ /** @deprecated use {@link #keyRotationTime()} */
@Deprecated @Deprecated
public @Nullable Date getKeyRotationTime() { public @Nullable Date getKeyRotationTime() {
Instant keyRotationTime = vKeyRotationTime; Instant keyRotationTime = vKeyRotationTime;

View file

@ -221,7 +221,7 @@ public class WalletProtobufSerializer {
} }
} }
Optional<Instant> keyRotationTime = wallet.getKeyRotationTimeInstant(); Optional<Instant> keyRotationTime = wallet.keyRotationTime();
if (keyRotationTime.isPresent()) { if (keyRotationTime.isPresent()) {
long timeSecs = keyRotationTime.get().getEpochSecond(); long timeSecs = keyRotationTime.get().getEpochSecond();
walletBuilder.setKeyRotationTime(timeSecs); walletBuilder.setKeyRotationTime(timeSecs);

View file

@ -2966,7 +2966,7 @@ public class WalletTest extends TestWithWallet {
Objects.requireNonNull(tx); Objects.requireNonNull(tx);
assertEquals(Transaction.Purpose.KEY_ROTATION, tx.getPurpose()); assertEquals(Transaction.Purpose.KEY_ROTATION, tx.getPurpose());
// Have to divide here to avoid mismatch due to second-level precision in serialisation. // Have to divide here to avoid mismatch due to second-level precision in serialisation.
assertEquals(compromiseTime, wallet.getKeyRotationTimeInstant().get()); assertEquals(compromiseTime, wallet.keyRotationTime().get());
// Make a normal spend and check it's all ok. // Make a normal spend and check it's all ok.
wallet.sendCoins(broadcaster, OTHER_ADDRESS, wallet.getBalance()); wallet.sendCoins(broadcaster, OTHER_ADDRESS, wallet.getBalance());