@Test(expected = IllegalStateException.class) public void isWatchingNoKeys() { group = new KeyChainGroup(PARAMS); group.isWatching(); }
public boolean isWatching() { BasicKeyChain.State basicState = basic.isWatching(); BasicKeyChain.State activeState = BasicKeyChain.State.EMPTY; if (!chains.isEmpty()) { if (getActiveKeyChain().isWatching()) activeState = BasicKeyChain.State.WATCHING; else activeState = BasicKeyChain.State.REGULAR; } if (basicState == BasicKeyChain.State.EMPTY) { if (activeState == BasicKeyChain.State.EMPTY) throw new IllegalStateException("Empty key chain group: cannot answer isWatching() query"); return activeState == BasicKeyChain.State.WATCHING; } else if (activeState == BasicKeyChain.State.EMPTY) return basicState == BasicKeyChain.State.WATCHING; else { if (activeState != basicState) throw new IllegalStateException("Mix of watching and non-watching keys in wallet"); return activeState == BasicKeyChain.State.WATCHING; } }
KeyChainGroup implements KeyBag { public boolean isWatching() { BasicKeyChain.State basicState = basic.isWatching(); BasicKeyChain.State activeState = BasicKeyChain.State.EMPTY; if (!chains.isEmpty()) { if (getActiveKeyChain().isWatching()) activeState = BasicKeyChain.State.WATCHING; else activeState = BasicKeyChain.State.REGULAR; } if (basicState == BasicKeyChain.State.EMPTY) { if (activeState == BasicKeyChain.State.EMPTY) throw new IllegalStateException("Empty key chain group: cannot answer isWatching() query"); return activeState == BasicKeyChain.State.WATCHING; } else if (activeState == BasicKeyChain.State.EMPTY) return basicState == BasicKeyChain.State.WATCHING; else { if (activeState != basicState) throw new IllegalStateException("Mix of watching and non-watching keys in wallet"); return activeState == BasicKeyChain.State.WATCHING; } } }
KeyChainGroup implements KeyBag { public boolean isWatching() { BasicKeyChain.State basicState = basic.isWatching(); BasicKeyChain.State activeState = BasicKeyChain.State.EMPTY; if (!chains.isEmpty()) { if (getActiveKeyChain().isWatching()) activeState = BasicKeyChain.State.WATCHING; else activeState = BasicKeyChain.State.REGULAR; } if (basicState == BasicKeyChain.State.EMPTY) { if (activeState == BasicKeyChain.State.EMPTY) throw new IllegalStateException("Empty key chain group: cannot answer isWatching() query"); return activeState == BasicKeyChain.State.WATCHING; } else if (activeState == BasicKeyChain.State.EMPTY) return basicState == BasicKeyChain.State.WATCHING; else { if (activeState != basicState) throw new IllegalStateException("Mix of watching and non-watching keys in wallet"); return activeState == BasicKeyChain.State.WATCHING; } } KeyChainGroup(NetworkParameters params);  KeyChainGroup(NetworkParameters params, DeterministicSeed seed);  KeyChainGroup(NetworkParameters params, DeterministicSeed seed, ImmutableList<ChildNumber> accountPath);  KeyChainGroup(NetworkParameters params, DeterministicKey watchKey); private  KeyChainGroup(NetworkParameters params, @Nullable BasicKeyChain basicKeyChain, List<DeterministicKeyChain> chains,
                          @Nullable EnumMap<KeyChain.KeyPurpose, DeterministicKey> currentKeys, @Nullable KeyCrypter crypter); }
KeyChainGroup implements KeyBag { public boolean isWatching() { BasicKeyChain.State basicState = basic.isWatching(); BasicKeyChain.State activeState = BasicKeyChain.State.EMPTY; if (!chains.isEmpty()) { if (getActiveKeyChain().isWatching()) activeState = BasicKeyChain.State.WATCHING; else activeState = BasicKeyChain.State.REGULAR; } if (basicState == BasicKeyChain.State.EMPTY) { if (activeState == BasicKeyChain.State.EMPTY) throw new IllegalStateException("Empty key chain group: cannot answer isWatching() query"); return activeState == BasicKeyChain.State.WATCHING; } else if (activeState == BasicKeyChain.State.EMPTY) return basicState == BasicKeyChain.State.WATCHING; else { if (activeState != basicState) throw new IllegalStateException("Mix of watching and non-watching keys in wallet"); return activeState == BasicKeyChain.State.WATCHING; } } KeyChainGroup(NetworkParameters params);  KeyChainGroup(NetworkParameters params, DeterministicSeed seed);  KeyChainGroup(NetworkParameters params, DeterministicSeed seed, ImmutableList<ChildNumber> accountPath);  KeyChainGroup(NetworkParameters params, DeterministicKey watchKey); private  KeyChainGroup(NetworkParameters params, @Nullable BasicKeyChain basicKeyChain, List<DeterministicKeyChain> chains,
                          @Nullable EnumMap<KeyChain.KeyPurpose, DeterministicKey> currentKeys, @Nullable KeyCrypter crypter); void createAndActivateNewHDChain(); void addAndActivateHDChain(DeterministicKeyChain chain); DeterministicKey currentKey(KeyChain.KeyPurpose purpose); Address currentAddress(KeyChain.KeyPurpose purpose); DeterministicKey freshKey(KeyChain.KeyPurpose purpose); List<DeterministicKey> freshKeys(KeyChain.KeyPurpose purpose, int numberOfKeys); Address freshAddress(KeyChain.KeyPurpose purpose); final DeterministicKeyChain getActiveKeyChain(); void setLookaheadSize(int lookaheadSize); int getLookaheadSize(); void setLookaheadThreshold(int num); int getLookaheadThreshold(); int importKeys(List<ECKey> keys); int importKeys(ECKey... keys); boolean checkPassword(CharSequence password); boolean checkAESKey(KeyParameter aesKey); int importKeysAndEncrypt(final List<ECKey> keys, KeyParameter aesKey); @Override @Nullable RedeemData findRedeemDataFromScriptHash(byte[] scriptHash); void markP2SHAddressAsUsed(Address address); @Nullable @Override ECKey findKeyFromPubHash(byte[] pubkeyHash); void markPubKeyHashAsUsed(byte[] pubkeyHash); boolean hasKey(ECKey key); @Nullable @Override ECKey findKeyFromPubKey(byte[] pubkey); void markPubKeyAsUsed(byte[] pubkey); int numKeys(); boolean removeImportedKey(ECKey key); final boolean isMarried(); void encrypt(KeyCrypter keyCrypter, KeyParameter aesKey); void decrypt(KeyParameter aesKey); boolean isEncrypted(); boolean isWatching(); @Nullable KeyCrypter getKeyCrypter(); List<ECKey> getImportedKeys(); long getEarliestKeyCreationTime(); int getBloomFilterElementCount(); BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak); boolean isRequiringUpdateAllBloomFilter(); void addEventListener(KeyChainEventListener listener); void addEventListener(KeyChainEventListener listener, Executor executor); boolean removeEventListener(KeyChainEventListener listener); List<Protos.Key> serializeToProtobuf(); static KeyChainGroup fromProtobufUnencrypted(NetworkParameters params, List<Protos.Key> keys, KeyChainFactory factory); static KeyChainGroup fromProtobufEncrypted(NetworkParameters params, List<Protos.Key> keys, KeyCrypter crypter, KeyChainFactory factory); DeterministicKeyChain upgradeToDeterministic(long keyRotationTimeSecs, @Nullable KeyParameter aesKey); boolean isDeterministicUpgradeRequired(); String toString(boolean includePrivateKeys); List<DeterministicKeyChain> getDeterministicKeyChains(); int getCombinedKeyLookaheadEpochs(); }
KeyChainGroup implements KeyBag { public boolean isWatching() { BasicKeyChain.State basicState = basic.isWatching(); BasicKeyChain.State activeState = BasicKeyChain.State.EMPTY; if (!chains.isEmpty()) { if (getActiveKeyChain().isWatching()) activeState = BasicKeyChain.State.WATCHING; else activeState = BasicKeyChain.State.REGULAR; } if (basicState == BasicKeyChain.State.EMPTY) { if (activeState == BasicKeyChain.State.EMPTY) throw new IllegalStateException("Empty key chain group: cannot answer isWatching() query"); return activeState == BasicKeyChain.State.WATCHING; } else if (activeState == BasicKeyChain.State.EMPTY) return basicState == BasicKeyChain.State.WATCHING; else { if (activeState != basicState) throw new IllegalStateException("Mix of watching and non-watching keys in wallet"); return activeState == BasicKeyChain.State.WATCHING; } } KeyChainGroup(NetworkParameters params);  KeyChainGroup(NetworkParameters params, DeterministicSeed seed);  KeyChainGroup(NetworkParameters params, DeterministicSeed seed, ImmutableList<ChildNumber> accountPath);  KeyChainGroup(NetworkParameters params, DeterministicKey watchKey); private  KeyChainGroup(NetworkParameters params, @Nullable BasicKeyChain basicKeyChain, List<DeterministicKeyChain> chains,
                          @Nullable EnumMap<KeyChain.KeyPurpose, DeterministicKey> currentKeys, @Nullable KeyCrypter crypter); void createAndActivateNewHDChain(); void addAndActivateHDChain(DeterministicKeyChain chain); DeterministicKey currentKey(KeyChain.KeyPurpose purpose); Address currentAddress(KeyChain.KeyPurpose purpose); DeterministicKey freshKey(KeyChain.KeyPurpose purpose); List<DeterministicKey> freshKeys(KeyChain.KeyPurpose purpose, int numberOfKeys); Address freshAddress(KeyChain.KeyPurpose purpose); final DeterministicKeyChain getActiveKeyChain(); void setLookaheadSize(int lookaheadSize); int getLookaheadSize(); void setLookaheadThreshold(int num); int getLookaheadThreshold(); int importKeys(List<ECKey> keys); int importKeys(ECKey... keys); boolean checkPassword(CharSequence password); boolean checkAESKey(KeyParameter aesKey); int importKeysAndEncrypt(final List<ECKey> keys, KeyParameter aesKey); @Override @Nullable RedeemData findRedeemDataFromScriptHash(byte[] scriptHash); void markP2SHAddressAsUsed(Address address); @Nullable @Override ECKey findKeyFromPubHash(byte[] pubkeyHash); void markPubKeyHashAsUsed(byte[] pubkeyHash); boolean hasKey(ECKey key); @Nullable @Override ECKey findKeyFromPubKey(byte[] pubkey); void markPubKeyAsUsed(byte[] pubkey); int numKeys(); boolean removeImportedKey(ECKey key); final boolean isMarried(); void encrypt(KeyCrypter keyCrypter, KeyParameter aesKey); void decrypt(KeyParameter aesKey); boolean isEncrypted(); boolean isWatching(); @Nullable KeyCrypter getKeyCrypter(); List<ECKey> getImportedKeys(); long getEarliestKeyCreationTime(); int getBloomFilterElementCount(); BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak); boolean isRequiringUpdateAllBloomFilter(); void addEventListener(KeyChainEventListener listener); void addEventListener(KeyChainEventListener listener, Executor executor); boolean removeEventListener(KeyChainEventListener listener); List<Protos.Key> serializeToProtobuf(); static KeyChainGroup fromProtobufUnencrypted(NetworkParameters params, List<Protos.Key> keys, KeyChainFactory factory); static KeyChainGroup fromProtobufEncrypted(NetworkParameters params, List<Protos.Key> keys, KeyCrypter crypter, KeyChainFactory factory); DeterministicKeyChain upgradeToDeterministic(long keyRotationTimeSecs, @Nullable KeyParameter aesKey); boolean isDeterministicUpgradeRequired(); String toString(boolean includePrivateKeys); List<DeterministicKeyChain> getDeterministicKeyChains(); int getCombinedKeyLookaheadEpochs();  }