/** Returns a freshly derived key that has not been returned by this method before. */ @Override public DeterministicKey getKey(KeyPurpose purpose) { return getKeys(purpose, 1).get(0); }
/** Returns a freshly derived key that has not been returned by this method before. */ @Override public DeterministicKey getKey(KeyPurpose purpose) { return getKeys(purpose, 1).get(0); }
/** Returns a freshly derived key that has not been returned by this method before. */ @Override public DeterministicKey getKey(KeyPurpose purpose) { return getKeys(purpose, 1).get(0); }
/** Returns a freshly derived key that has not been returned by this method before. */ @Override public DeterministicKey getKey(KeyPurpose purpose) { return getKeys(purpose, 1).get(0); }
protected void formatAddresses(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params, StringBuilder builder) { for (ECKey key : getKeys(false, true)) key.formatKeyWithAddress(includePrivateKeys, aesKey, builder, params); }
protected void formatAddresses(boolean includePrivateKeys, NetworkParameters params, StringBuilder builder) { for (ECKey key : getKeys(false, true)) key.formatKeyWithAddress(includePrivateKeys, builder, params); }
protected void formatAddresses(boolean includePrivateKeys, NetworkParameters params, StringBuilder builder2) { for (ECKey key : getKeys(false)) key.formatKeyWithAddress(includePrivateKeys, builder2, params); }
protected void formatAddresses(boolean includePrivateKeys, NetworkParameters params, StringBuilder builder2) { for (ECKey key : getKeys(false)) key.formatKeyWithAddress(includePrivateKeys, builder2, params); }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<ECKey>(getKeys(false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<ECKey>(getKeys(false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns leaf keys issued by this chain (including lookahead zone) */ public List<DeterministicKey> getLeafKeys() { ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder(); for (ECKey key : getKeys(true)) { DeterministicKey dKey = (DeterministicKey) key; if (dKey.getPath().size() == getAccountPath().size() + 2) { keys.add(dKey); } } return keys.build(); }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<>(getKeys(false, false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<>(getKeys(false, false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns leaf keys issued by this chain (including lookahead zone) */ public List<DeterministicKey> getLeafKeys() { ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder(); for (ECKey key : getKeys(true, false)) { DeterministicKey dKey = (DeterministicKey) key; if (dKey.getPath().size() == getAccountPath().size() + 2) { keys.add(dKey); } } return keys.build(); }
/** * Returns leaf keys issued by this chain (including lookahead zone) */ public List<DeterministicKey> getLeafKeys() { ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder(); for (ECKey key : getKeys(true, false)) { DeterministicKey dKey = (DeterministicKey) key; if (dKey.getPath().size() == getAccountPath().size() + 2) { keys.add(dKey); } } return keys.build(); }
/** * Returns leaf keys issued by this chain (including lookahead zone) */ public List<DeterministicKey> getLeafKeys() { ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder(); for (ECKey key : getKeys(true)) { DeterministicKey dKey = (DeterministicKey) key; if (dKey.getPath().size() == getAccountPath().size() + 2) { keys.add(dKey); } } return keys.build(); }
/** * Returns a key/s that have not been returned by this method before (fresh). You can think of this as being * newly created key/s, although the notion of "create" is not really valid for a * {@link DeterministicKeyChain}. When the parameter is * {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} the returned key is suitable for being put * into a receive coins wizard type UI. You should use this when the user is definitely going to hand this key out * to someone who wishes to send money. * <p>This method is not supposed to be used for married keychains and will throw UnsupportedOperationException if * the active chain is married. * For married keychains use {@link #freshAddress(KeyChain.KeyPurpose)} * to get a proper P2SH address</p> */ public List<DeterministicKey> freshKeys(KeyChain.KeyPurpose purpose, int numberOfKeys) { DeterministicKeyChain chain = getActiveKeyChain(); if (chain.isMarried()) { throw new UnsupportedOperationException("Key is not suitable to receive coins for married keychains." + " Use freshAddress to get P2SH address instead"); } return chain.getKeys(purpose, numberOfKeys); // Always returns the next key along the key chain. }
/** * Returns a key/s that have not been returned by this method before (fresh). You can think of this as being * newly created key/s, although the notion of "create" is not really valid for a * {@link DeterministicKeyChain}. When the parameter is * {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} the returned key is suitable for being put * into a receive coins wizard type UI. You should use this when the user is definitely going to hand this key out * to someone who wishes to send money. * <p>This method is not supposed to be used for married keychains and will throw UnsupportedOperationException if * the active chain is married. * For married keychains use {@link #freshAddress(KeyChain.KeyPurpose)} * to get a proper P2SH address</p> */ public List<DeterministicKey> freshKeys(KeyChain.KeyPurpose purpose, int numberOfKeys) { DeterministicKeyChain chain = getActiveKeyChain(); if (chain.isMarried()) { throw new UnsupportedOperationException("Key is not suitable to receive coins for married keychains." + " Use freshAddress to get P2SH address instead"); } return chain.getKeys(purpose, numberOfKeys); // Always returns the next key along the key chain. }
/** Returns the redeem script by its hash or null if this keychain did not generate the script. */ @Nullable public RedeemData findRedeemDataByScriptHash(ByteString bytes) { if (this.useSegwit) { for(ECKey key: getKeys(false, true)) { // see if this is a P2SH-of-P2WPKH for one of our keys Script pay2wpkh = ScriptBuilder.createP2WPKHOutputScript(key); Script pay2sh = ScriptBuilder.createP2SHOutputScript(pay2wpkh); if (Arrays.equals(pay2sh.getPubKeyHash(), bytes.toByteArray())) { return RedeemData.of(key, pay2wpkh, true); } } } return null; } }
@Test public void getKeys() throws Exception { chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS); chain.getKey(KeyChain.KeyPurpose.CHANGE); chain.maybeLookAhead(); assertEquals(2, chain.getKeys(false, false).size()); }