Guard BasicKeyChain.importKey*() against accidently importing the same key twice, potentially losing a private key.

This commit is contained in:
Andreas Schildbach
2014-12-11 21:40:16 +01:00
parent e5bc481743
commit eb24bafdbc

View File

@@ -167,8 +167,9 @@ public class BasicKeyChain implements EncryptableKeyChain {
}
private void importKeyLocked(ECKey key) {
pubkeyToKeys.put(ByteString.copyFrom(key.getPubKey()), key);
ECKey previousKey = pubkeyToKeys.put(ByteString.copyFrom(key.getPubKey()), key);
hashToKeys.put(ByteString.copyFrom(key.getPubKeyHash()), key);
checkState(previousKey == null);
}
private void importKeysLocked(List<ECKey> keys) {