@Test public void removeKey() { ECKey key = new ECKey(); chain.importKeys(key); assertEquals(1, chain.numKeys()); assertTrue(chain.removeKey(key)); assertEquals(0, chain.numKeys()); assertFalse(chain.removeKey(key)); }
public boolean removeKey(ECKey key) { lock.lock(); try { boolean a = hashToKeys.remove(ByteString.copyFrom(key.getPubKeyHash())) != null; boolean b = pubkeyToKeys.remove(ByteString.copyFrom(key.getPubKey())) != null; checkState(a == b); return a; } finally { lock.unlock(); } }
BasicKeyChain implements EncryptableKeyChain { public boolean removeKey(ECKey key) { lock.lock(); try { boolean a = hashToKeys.remove(ByteString.copyFrom(key.getPubKeyHash())) != null; boolean b = pubkeyToKeys.remove(ByteString.copyFrom(key.getPubKey())) != null; checkState(a == b); return a; } finally { lock.unlock(); } } }
BasicKeyChain implements EncryptableKeyChain { public boolean removeKey(ECKey key) { lock.lock(); try { boolean a = hashToKeys.remove(ByteString.copyFrom(key.getPubKeyHash())) != null; boolean b = pubkeyToKeys.remove(ByteString.copyFrom(key.getPubKey())) != null; checkState(a == b); return a; } finally { lock.unlock(); } } BasicKeyChain();  BasicKeyChain(@Nullable KeyCrypter crypter); }
BasicKeyChain implements EncryptableKeyChain { public boolean removeKey(ECKey key) { lock.lock(); try { boolean a = hashToKeys.remove(ByteString.copyFrom(key.getPubKeyHash())) != null; boolean b = pubkeyToKeys.remove(ByteString.copyFrom(key.getPubKey())) != null; checkState(a == b); return a; } finally { lock.unlock(); } } BasicKeyChain();  BasicKeyChain(@Nullable KeyCrypter crypter); @Override @Nullable KeyCrypter getKeyCrypter(); @Override ECKey getKey(@Nullable KeyPurpose ignored); @Override List<ECKey> getKeys(@Nullable KeyPurpose purpose, int numberOfKeys); List<ECKey> getKeys(); int importKeys(ECKey... keys); int importKeys(List<? extends ECKey> keys); void importKey(ECKey key); ECKey findKeyFromPubHash(byte[] pubkeyHash); ECKey findKeyFromPubKey(byte[] pubkey); @Override boolean hasKey(ECKey key); @Override int numKeys(); State isWatching(); boolean removeKey(ECKey key); @Override long getEarliestKeyCreationTime(); List<ListenerRegistration<KeyChainEventListener>> getListeners(); @Override List<Protos.Key> serializeToProtobuf(); static BasicKeyChain fromProtobufUnencrypted(List<Protos.Key> keys); static BasicKeyChain fromProtobufEncrypted(List<Protos.Key> keys, KeyCrypter crypter); @Override void addEventListener(KeyChainEventListener listener); @Override void addEventListener(KeyChainEventListener listener, Executor executor); @Override boolean removeEventListener(KeyChainEventListener listener); @Override BasicKeyChain toEncrypted(CharSequence password); @Override BasicKeyChain toEncrypted(KeyCrypter keyCrypter, KeyParameter aesKey); @Override BasicKeyChain toDecrypted(CharSequence password); @Override BasicKeyChain toDecrypted(KeyParameter aesKey); @Override boolean checkPassword(CharSequence password); @Override boolean checkAESKey(KeyParameter aesKey); @Override BloomFilter getFilter(int size, double falsePositiveRate, long tweak); @Override int numBloomFilterEntries(); @Nullable ECKey findOldestKeyAfter(long timeSecs); List<ECKey> findKeysBefore(long timeSecs); }
BasicKeyChain implements EncryptableKeyChain { public boolean removeKey(ECKey key) { lock.lock(); try { boolean a = hashToKeys.remove(ByteString.copyFrom(key.getPubKeyHash())) != null; boolean b = pubkeyToKeys.remove(ByteString.copyFrom(key.getPubKey())) != null; checkState(a == b); return a; } finally { lock.unlock(); } } BasicKeyChain();  BasicKeyChain(@Nullable KeyCrypter crypter); @Override @Nullable KeyCrypter getKeyCrypter(); @Override ECKey getKey(@Nullable KeyPurpose ignored); @Override List<ECKey> getKeys(@Nullable KeyPurpose purpose, int numberOfKeys); List<ECKey> getKeys(); int importKeys(ECKey... keys); int importKeys(List<? extends ECKey> keys); void importKey(ECKey key); ECKey findKeyFromPubHash(byte[] pubkeyHash); ECKey findKeyFromPubKey(byte[] pubkey); @Override boolean hasKey(ECKey key); @Override int numKeys(); State isWatching(); boolean removeKey(ECKey key); @Override long getEarliestKeyCreationTime(); List<ListenerRegistration<KeyChainEventListener>> getListeners(); @Override List<Protos.Key> serializeToProtobuf(); static BasicKeyChain fromProtobufUnencrypted(List<Protos.Key> keys); static BasicKeyChain fromProtobufEncrypted(List<Protos.Key> keys, KeyCrypter crypter); @Override void addEventListener(KeyChainEventListener listener); @Override void addEventListener(KeyChainEventListener listener, Executor executor); @Override boolean removeEventListener(KeyChainEventListener listener); @Override BasicKeyChain toEncrypted(CharSequence password); @Override BasicKeyChain toEncrypted(KeyCrypter keyCrypter, KeyParameter aesKey); @Override BasicKeyChain toDecrypted(CharSequence password); @Override BasicKeyChain toDecrypted(KeyParameter aesKey); @Override boolean checkPassword(CharSequence password); @Override boolean checkAESKey(KeyParameter aesKey); @Override BloomFilter getFilter(int size, double falsePositiveRate, long tweak); @Override int numBloomFilterEntries(); @Nullable ECKey findOldestKeyAfter(long timeSecs); List<ECKey> findKeysBefore(long timeSecs);  }