/** * Creates a deterministic key chain that watches the given (public only) root key. You can use this to calculate * balances and generally follow along, but spending is not possible with such a chain. Currently you can't use * this method to watch an arbitrary fragment of some other tree, this limitation may be removed in future. */ public SimpleHDKeyChain(DeterministicKey rootkey) { simpleKeyChain = new SimpleKeyChain(); initializeHierarchyUnencrypted(rootkey); }
SimpleHDKeyChain(DeterministicKey rootkey, @Nullable KeyCrypter crypter) { this.rootKey = rootkey; simpleKeyChain = new SimpleKeyChain(crypter); if (!rootkey.isEncrypted()) { initializeHierarchyUnencrypted(rootKey); } // Else... // We can't initialize ourselves with just an encrypted seed, so we expected deserialization code to do the // rest of the setup (loading the root key). }
SimpleHDKeyChain(DeterministicKey rootkey, @Nullable KeyCrypter crypter, @Nullable KeyParameter key) { simpleKeyChain = new SimpleKeyChain(crypter); if (crypter != null && !rootkey.isEncrypted()) { this.rootKey = rootkey.encrypt(crypter, key, null); } else { this.rootKey = rootkey; } initializeHierarchyUnencrypted(rootKey); }
public BitWalletSingleKey(CoinType coinType, ECKey key) { super(checkNotNull(coinType), Wallet.generateRandomId()); keys = new SimpleKeyChain(); keys.importKey(key); }
private SimpleHDKeyChain(KeyCrypter crypter, KeyParameter aesKey, SimpleHDKeyChain chain) { checkArgument(!chain.rootKey.isEncrypted(), "Chain already encrypted"); this.issuedExternalKeys = chain.issuedExternalKeys; this.issuedInternalKeys = chain.issuedInternalKeys; this.lookaheadSize = chain.lookaheadSize; this.lookaheadThreshold = chain.lookaheadThreshold; simpleKeyChain = new SimpleKeyChain(crypter); // The first number is the "account number" but we don't use that feature. rootKey = chain.rootKey.encrypt(crypter, aesKey, null); hierarchy = new DeterministicHierarchy(rootKey); simpleKeyChain.importKey(rootKey); externalKey = encryptNonLeaf(aesKey, chain, rootKey, EXTERNAL_PATH); internalKey = encryptNonLeaf(aesKey, chain, rootKey, INTERNAL_PATH); // Now copy the (pubkey only) leaf keys across to avoid rederiving them. The private key bytes are missing // anyway so there's nothing to encrypt. for (ECKey eckey : chain.simpleKeyChain.getKeys()) { DeterministicKey key = (DeterministicKey) eckey; if (!isLeaf(key)) continue; // Not a leaf key. DeterministicKey parent = hierarchy.get(checkNotNull(key.getParent(), "Key has no parent").getPath(), false, false); // Clone the key to the new encrypted hierarchy. key = new DeterministicKey(key.getPubOnly(), parent); hierarchy.putKey(key); simpleKeyChain.importKey(key); } }