3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-11 17:55:53 +00:00

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) {