/** * Sets the lookahead buffer size for ALL deterministic key chains as well as for following key chains if any exist, * see {@link DeterministicKeyChain#setLookaheadSize(int)} * for more information. */ public void setLookaheadSize(int lookaheadSize) { this.lookaheadSize = lookaheadSize; for (DeterministicKeyChain chain : chains) { chain.setLookaheadSize(lookaheadSize); } }
/** * Sets the lookahead buffer size for ALL deterministic key chains as well as for following key chains if any exist, * see {@link DeterministicKeyChain#setLookaheadSize(int)} * for more information. */ public void setLookaheadSize(int lookaheadSize) { this.lookaheadSize = lookaheadSize; for (DeterministicKeyChain chain : chains) { chain.setLookaheadSize(lookaheadSize); } }
/** * Sets the lookahead buffer size for ALL deterministic key chains as well as for following key chains if any exist, * see {@link DeterministicKeyChain#setLookaheadSize(int)} * for more information. */ public void setLookaheadSize(int lookaheadSize) { this.lookaheadSize = lookaheadSize; for (DeterministicKeyChain chain : chains) { chain.setLookaheadSize(lookaheadSize); } }
/** * Sets the lookahead buffer size for ALL deterministic key chains as well as for following key chains if any exist, * see {@link DeterministicKeyChain#setLookaheadSize(int)} * for more information. */ public void setLookaheadSize(int lookaheadSize) { this.lookaheadSize = lookaheadSize; for (DeterministicKeyChain chain : chains) { chain.setLookaheadSize(lookaheadSize); } }
@Override public void setLookaheadSize(int lookaheadSize) { lock.lock(); try { super.setLookaheadSize(lookaheadSize); if (followingKeyChains != null) { for (DeterministicKeyChain followingChain : followingKeyChains) { followingChain.setLookaheadSize(lookaheadSize); } } } finally { lock.unlock(); } }
@Override public void setLookaheadSize(int lookaheadSize) { lock.lock(); try { super.setLookaheadSize(lookaheadSize); if (followingKeyChains != null) { for (DeterministicKeyChain followingChain : followingKeyChains) { followingChain.setLookaheadSize(lookaheadSize); } } } finally { lock.unlock(); } }
@Override public void setLookaheadSize(int lookaheadSize) { lock.lock(); try { super.setLookaheadSize(lookaheadSize); if (followingKeyChains != null) { for (DeterministicKeyChain followingChain : followingKeyChains) { followingChain.setLookaheadSize(lookaheadSize); } } } finally { lock.unlock(); } }
@Override public void setLookaheadSize(int lookaheadSize) { lock.lock(); try { super.setLookaheadSize(lookaheadSize); if (followingKeyChains != null) { for (DeterministicKeyChain followingChain : followingKeyChains) { followingChain.setLookaheadSize(lookaheadSize); } } } finally { lock.unlock(); } }
private void addFollowingAccountKeys(List<DeterministicKey> followingAccountKeys, int sigsRequiredToSpend) { checkArgument(sigsRequiredToSpend <= followingAccountKeys.size() + 1, "Multisig threshold can't exceed total number of keys"); checkState(numLeafKeysIssued() == 0, "Active keychain already has keys in use"); checkState(followingKeyChains == null); List<DeterministicKeyChain> followingKeyChains = Lists.newArrayList(); for (DeterministicKey key : followingAccountKeys) { checkArgument(key.getPath().size() == getAccountPath().size(), "Following keys have to be account keys"); DeterministicKeyChain chain = DeterministicKeyChain.watchAndFollow(key); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); followingKeyChains.add(chain); } this.sigsRequiredToSpend = sigsRequiredToSpend; this.followingKeyChains = followingKeyChains; }
private void addFollowingAccountKeys(List<DeterministicKey> followingAccountKeys, int sigsRequiredToSpend) { checkArgument(sigsRequiredToSpend <= followingAccountKeys.size() + 1, "Multisig threshold can't exceed total number of keys"); checkState(numLeafKeysIssued() == 0, "Active keychain already has keys in use"); checkState(followingKeyChains == null); List<DeterministicKeyChain> followingKeyChains = Lists.newArrayList(); for (DeterministicKey key : followingAccountKeys) { checkArgument(key.getPath().size() == getAccountPath().size(), "Following keys have to be account keys"); DeterministicKeyChain chain = DeterministicKeyChain.watchAndFollow(key); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); followingKeyChains.add(chain); } this.sigsRequiredToSpend = sigsRequiredToSpend; this.followingKeyChains = followingKeyChains; }
/** * Adds an HD chain to the chains list, and make it the default chain (from which keys are issued). * Useful for adding a complex pre-configured keychain, such as a married wallet. */ public void addAndActivateHDChain(DeterministicKeyChain chain) { log.info("Creating and activating a new HD chain: {}", chain); for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners()) chain.addEventListener(registration.listener, registration.executor); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); chains.add(chain); }
private void addFollowingAccountKeys(List<DeterministicKey> followingAccountKeys, int sigsRequiredToSpend) { checkArgument(sigsRequiredToSpend <= followingAccountKeys.size() + 1, "Multisig threshold can't exceed total number of keys"); checkState(numLeafKeysIssued() == 0, "Active keychain already has keys in use"); checkState(followingKeyChains == null); List<DeterministicKeyChain> followingKeyChains = Lists.newArrayList(); for (DeterministicKey key : followingAccountKeys) { checkArgument(key.getPath().size() == getAccountPath().size(), "Following keys have to be account keys"); DeterministicKeyChain chain = DeterministicKeyChain.watchAndFollow(key); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); followingKeyChains.add(chain); } this.sigsRequiredToSpend = sigsRequiredToSpend; this.followingKeyChains = followingKeyChains; }
/** * Adds an HD chain to the chains list, and make it the default chain (from which keys are issued). * Useful for adding a complex pre-configured keychain, such as a married wallet. */ public void addAndActivateHDChain(DeterministicKeyChain chain) { log.info("Creating and activating a new HD chain: {}", chain); for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners()) chain.addEventListener(registration.listener, registration.executor); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); chains.add(chain); }
private void addFollowingAccountKeys(List<DeterministicKey> followingAccountKeys, int sigsRequiredToSpend) { checkArgument(sigsRequiredToSpend <= followingAccountKeys.size() + 1, "Multisig threshold can't exceed total number of keys"); checkState(numLeafKeysIssued() == 0, "Active keychain already has keys in use"); checkState(followingKeyChains == null); List<DeterministicKeyChain> followingKeyChains = Lists.newArrayList(); for (DeterministicKey key : followingAccountKeys) { checkArgument(key.getPath().size() == getAccountPath().size(), "Following keys have to be account keys"); DeterministicKeyChain chain = DeterministicKeyChain.watchAndFollow(key); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); followingKeyChains.add(chain); } this.sigsRequiredToSpend = sigsRequiredToSpend; this.followingKeyChains = followingKeyChains; }
/** * Adds an HD chain to the chains list, and make it the default chain (from which keys are issued). * Useful for adding a complex pre-configured keychain, such as a married wallet. */ public void addAndActivateHDChain(DeterministicKeyChain chain) { log.info("Creating and activating a new HD chain: {}", chain); for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners()) chain.addEventListener(registration.listener, registration.executor); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); chains.add(chain); }
/** * Adds an HD chain to the chains list, and make it the default chain (from which keys are issued). * Useful for adding a complex pre-configured keychain, such as a married wallet. */ public void addAndActivateHDChain(DeterministicKeyChain chain) { log.info("Creating and activating a new HD chain: {}", chain); for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners()) chain.addEventListener(registration.listener, registration.executor); if (lookaheadSize >= 0) chain.setLookaheadSize(lookaheadSize); if (lookaheadThreshold >= 0) chain.setLookaheadThreshold(lookaheadThreshold); chains.add(chain); }
@Test public void random() { // Can't test much here but verify the constructor worked and the class is functional. The other tests rely on // a fixed seed to be deterministic. chain = new DeterministicKeyChain(new SecureRandom(), 384); chain.setLookaheadSize(10); chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).sign(Sha256Hash.ZERO_HASH); chain.getKey(KeyChain.KeyPurpose.CHANGE).sign(Sha256Hash.ZERO_HASH); }
@Before public void setup() { BriefLogFormatter.init(); // You should use a random seed instead. The secs constant comes from the unit test file, so we can compare // serialized data properly. long secs = 1389353062L; chain = new DeterministicKeyChain(ENTROPY, "", secs); chain.setLookaheadSize(10); assertEquals(secs, checkNotNull(chain.getSeed()).getCreationTimeSeconds()); }
chain.setLookaheadSize(5); assertEquals(0, listenerKeys.size()); ECKey key = chain.getKey(KeyChain.KeyPurpose.CHANGE);
chain = DeterministicKeyChain.watch(watchingKey); assertEquals(100000, chain.getEarliestKeyCreationTime()); chain.setLookaheadSize(10); chain.maybeLookAhead();