Key rotation: remove the enabled setting. It's no longer useful and defaulted to off, which is dangerous and can lead to bugs.

This commit is contained in:
Mike Hearn
2014-10-22 15:42:29 +02:00
parent db519475b2
commit 77ace479d9
3 changed files with 1 additions and 13 deletions

View File

@@ -187,7 +187,6 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
// UNIX time in seconds. Money controlled by keys created before this time will be automatically respent to a key
// that was created after it. Useful when you believe some keys have been compromised.
private volatile long vKeyRotationTimestamp;
private volatile boolean vKeyRotationEnabled;
protected transient CoinSelector coinSelector = new DefaultCoinSelector();
@@ -451,7 +450,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
public void upgradeToDeterministic(@Nullable KeyParameter aesKey) throws DeterministicUpgradeRequiresPassword {
lock.lock();
try {
keychain.upgradeToDeterministic(vKeyRotationEnabled ? vKeyRotationTimestamp : 0, aesKey);
keychain.upgradeToDeterministic(vKeyRotationTimestamp, aesKey);
} finally {
lock.unlock();
}
@@ -4295,11 +4294,6 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
saveNow();
}
/** Toggles key rotation on and off. Note that this state is not serialized. */
public void setKeyRotationEnabled(boolean enabled) {
vKeyRotationEnabled = enabled;
}
/** Returns whether the keys creation time is before the key rotation time, if one was set. */
public boolean isKeyRotating(ECKey key) {
long time = vKeyRotationTimestamp;
@@ -4357,8 +4351,6 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
checkState(lock.isHeldByCurrentThread());
List<Transaction> results = Lists.newLinkedList();
// TODO: Handle chain replays here.
if (!vKeyRotationEnabled) return results;
// Snapshot volatiles so this method has an atomic view.
long keyRotationTimestamp = vKeyRotationTimestamp;
if (keyRotationTimestamp == 0) return results; // Nothing to do.

View File

@@ -2288,7 +2288,6 @@ public class WalletTest extends TestWithWallet {
wallet = new Wallet(params);
// Watch out for wallet-initiated broadcasts.
MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet);
wallet.setKeyRotationEnabled(true);
// Send three cents to two different random keys, then add a key and mark the initial keys as compromised.
ECKey key1 = new ECKey();
key1.setCreationTimeSeconds(Utils.currentTimeSeconds() - (86400 * 2));
@@ -2375,7 +2374,6 @@ public class WalletTest extends TestWithWallet {
// A day later, we get compromised.
Utils.rollMockClock(86400);
wallet.setKeyRotationTime(Utils.currentTimeSeconds());
wallet.setKeyRotationEnabled(true);
List<Transaction> txns = wallet.maybeDoMaintenance(null, false).get();
assertEquals(1, txns.size());
@@ -2400,7 +2398,6 @@ public class WalletTest extends TestWithWallet {
}
MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet);
wallet.setKeyRotationEnabled(true);
Date compromise = Utils.now();
Utils.rollMockClock(86400);

View File

@@ -448,7 +448,6 @@ public class WalletTool {
rotationTimeSecs = options.valueOf(dateFlag).getTime() / 1000;
}
log.info("Setting wallet key rotation time to {}", rotationTimeSecs);
wallet.setKeyRotationEnabled(true);
wallet.setKeyRotationTime(rotationTimeSecs);
KeyParameter aesKey = null;
if (wallet.isEncrypted()) {