@Test public void importKeys() { long now = Utils.currentTimeSeconds(); Utils.setMockClock(now); final ECKey key1 = new ECKey(); Utils.rollMockClock(86400); final ECKey key2 = new ECKey(); final ArrayList<ECKey> keys = Lists.newArrayList(key1, key2); assertEquals(2, chain.importKeys(keys)); assertEquals(2, chain.numKeys()); assertTrue(onKeysAddedRan.getAndSet(false)); assertArrayEquals(keys.toArray(), onKeysAdded.get().toArray()); assertEquals(now, chain.getEarliestKeyCreationTime()); final ECKey newKey = new ECKey(); keys.add(newKey); assertEquals(1, chain.importKeys(keys)); assertTrue(onKeysAddedRan.getAndSet(false)); assertEquals(newKey, onKeysAdded.getAndSet(null).get(0)); assertEquals(0, chain.importKeys(keys)); assertFalse(onKeysAddedRan.getAndSet(false)); assertNull(onKeysAdded.get()); assertTrue(chain.hasKey(key1)); assertTrue(chain.hasKey(key2)); assertEquals(key1, chain.findKeyFromPubHash(key1.getPubKeyHash())); assertEquals(key2, chain.findKeyFromPubKey(key2.getPubKey())); assertNull(chain.findKeyFromPubKey(key2.getPubKeyHash())); }
public int importKeys(ECKey... keys) { return importKeys(ImmutableList.copyOf(keys)); }
BasicKeyChain implements EncryptableKeyChain { public int importKeys(ECKey... keys) { return importKeys(ImmutableList.copyOf(keys)); } }
BasicKeyChain implements EncryptableKeyChain { public int importKeys(ECKey... keys) { return importKeys(ImmutableList.copyOf(keys)); } BasicKeyChain();  BasicKeyChain(@Nullable KeyCrypter crypter); }
BasicKeyChain implements EncryptableKeyChain { public int importKeys(ECKey... keys) { return importKeys(ImmutableList.copyOf(keys)); } 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); String toString(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params); }
BasicKeyChain implements EncryptableKeyChain { public int importKeys(ECKey... keys) { return importKeys(ImmutableList.copyOf(keys)); } 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); String toString(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params);  }