/** Returns true if this chain is watch only, meaning it has public keys but no private key. */ public boolean isWatching() { return getWatchingKey().isWatching(); }
/** Returns true if this chain is watch only, meaning it has public keys but no private key. */ public boolean isWatching() { return getWatchingKey().isWatching(); }
/** Returns true if this chain is watch only, meaning it has public keys but no private key. */ public boolean isWatching() { return getWatchingKey().isWatching(); }
/** Returns true if this chain is watch only, meaning it has public keys but no private key. */ public boolean isWatching() { return getWatchingKey().isWatching(); }
@Override protected void formatAddresses(boolean includePrivateKeys, NetworkParameters params, StringBuilder builder2) { for (DeterministicKeyChain followingChain : followingKeyChains) builder2.append("Following chain: ").append(followingChain.getWatchingKey().serializePubB58(params)) .append('\n'); builder2.append('\n'); for (RedeemData redeemData : marriedKeysRedeemData.values()) formatScript(ScriptBuilder.createP2SHOutputScript(redeemData.redeemScript), builder2, params); }
@Override protected void formatAddresses(boolean includePrivateKeys, NetworkParameters params, StringBuilder builder2) { for (DeterministicKeyChain followingChain : followingKeyChains) builder2.append("Following chain: ").append(followingChain.getWatchingKey().serializePubB58(params)) .append('\n'); builder2.append('\n'); for (RedeemData redeemData : marriedKeysRedeemData.values()) formatScript(ScriptBuilder.createP2SHOutputScript(redeemData.redeemScript), builder2, params); }
@Override protected void formatAddresses(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params, StringBuilder builder2) { for (DeterministicKeyChain followingChain : followingKeyChains) builder2.append("Following chain: ").append(followingChain.getWatchingKey().serializePubB58(params)) .append('\n'); builder2.append('\n'); for (RedeemData redeemData : marriedKeysRedeemData.values()) formatScript(ScriptBuilder.createP2SHOutputScript(redeemData.redeemScript), builder2, params); }
/** * Returns a public-only DeterministicKey that can be used to set up a watching wallet: that is, a wallet that * can import transactions from the block chain just as the normal wallet can, but which cannot spend. Watching * wallets are very useful for things like web servers that accept payments. This key corresponds to the account * zero key in the recommended BIP32 hierarchy. */ public DeterministicKey getWatchingKey() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.getActiveKeyChain().getWatchingKey(); } finally { keyChainGroupLock.unlock(); } }
@Override protected void formatAddresses(boolean includePrivateKeys, NetworkParameters params, StringBuilder builder2) { for (DeterministicKeyChain followingChain : followingKeyChains) builder2.append("Following chain: ").append(followingChain.getWatchingKey().serializePubB58(params)) .append('\n'); builder2.append('\n'); for (RedeemData redeemData : marriedKeysRedeemData.values()) formatScript(ScriptBuilder.createP2SHOutputScript(redeemData.redeemScript), builder2, params); }
/** * Returns a public-only DeterministicKey that can be used to set up a watching wallet: that is, a wallet that * can import transactions from the block chain just as the normal wallet can, but which cannot spend. Watching * wallets are very useful for things like web servers that accept payments. This key corresponds to the account * zero key in the recommended BIP32 hierarchy. */ public DeterministicKey getWatchingKey() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.getActiveKeyChain().getWatchingKey(); } finally { keyChainGroupLock.unlock(); } }
/** * Returns a public-only DeterministicKey that can be used to set up a watching wallet: that is, a wallet that * can import transactions from the block chain just as the normal wallet can, but which cannot spend. Watching * wallets are very useful for things like web servers that accept payments. This key corresponds to the account * zero key in the recommended BIP32 hierarchy. */ public DeterministicKey getWatchingKey() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.getActiveKeyChain().getWatchingKey(); } finally { keyChainGroupLock.unlock(); } }
/** * Returns a public-only DeterministicKey that can be used to set up a watching wallet: that is, a wallet that * can import transactions from the block chain just as the normal wallet can, but which cannot spend. Watching * wallets are very useful for things like web servers that accept payments. This key corresponds to the account * zero key in the recommended BIP32 hierarchy. */ public DeterministicKey getWatchingKey() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.getActiveKeyChain().getWatchingKey(); } finally { keyChainGroupLock.unlock(); } }
@Override public long getEarliestKeyCreationTime() { if (seed != null) return seed.getCreationTimeSeconds(); else return getWatchingKey().getCreationTimeSeconds(); }
@Override public long getEarliestKeyCreationTime() { if (seed != null) return seed.getCreationTimeSeconds(); else return getWatchingKey().getCreationTimeSeconds(); }
@Override public long getEarliestKeyCreationTime() { if (seed != null) return seed.getCreationTimeSeconds(); else return getWatchingKey().getCreationTimeSeconds(); }
@Override public long getEarliestKeyCreationTime() { if (seed != null) return seed.getCreationTimeSeconds(); else return getWatchingKey().getCreationTimeSeconds(); }
public String toString(boolean includePrivateKeys, NetworkParameters params) { final DeterministicKey watchingKey = getWatchingKey(); final StringBuilder builder = new StringBuilder(); if (seed != null) { if (seed.isEncrypted()) { builder.append("Seed is encrypted\n"); } else if (includePrivateKeys) { final List<String> words = seed.getMnemonicCode(); builder.append("Seed as words: ").append(Utils.join(words)).append('\n'); builder.append("Seed as hex: ").append(seed.toHexString()).append('\n'); } builder.append("Seed birthday: ").append(seed.getCreationTimeSeconds()).append(" [") .append(Utils.dateTimeFormat(seed.getCreationTimeSeconds() * 1000)).append("]\n"); } else { builder.append("Key birthday: ").append(watchingKey.getCreationTimeSeconds()).append(" [") .append(Utils.dateTimeFormat(watchingKey.getCreationTimeSeconds() * 1000)).append("]\n"); } builder.append("Key to watch: ").append(watchingKey.serializePubB58(params)).append('\n'); formatAddresses(includePrivateKeys, params, builder); return builder.toString(); }
private void createMarriedWallet(int threshold, int numKeys, boolean addSigners) throws BlockStoreException { wallet = new Wallet(PARAMS); blockStore = new MemoryBlockStore(PARAMS); chain = new BlockChain(PARAMS, wallet, blockStore); List<DeterministicKey> followingKeys = Lists.newArrayList(); for (int i = 0; i < numKeys - 1; i++) { final DeterministicKeyChain keyChain = new DeterministicKeyChain(new SecureRandom()); DeterministicKey partnerKey = DeterministicKey.deserializeB58(null, keyChain.getWatchingKey().serializePubB58(PARAMS), PARAMS); followingKeys.add(partnerKey); if (addSigners && i < threshold - 1) wallet.addTransactionSigner(new KeyChainTransactionSigner(keyChain)); } MarriedKeyChain chain = MarriedKeyChain.builder() .random(new SecureRandom()) .followingKeys(followingKeys) .threshold(threshold).build(); wallet.addAndActivateHDChain(chain); }
@Test public void testRoundTripMarriedWallet() throws Exception { // create 2-of-2 married wallet myWallet = new Wallet(PARAMS); final DeterministicKeyChain partnerChain = new DeterministicKeyChain(new SecureRandom()); DeterministicKey partnerKey = DeterministicKey.deserializeB58(null, partnerChain.getWatchingKey().serializePubB58(PARAMS), PARAMS); MarriedKeyChain chain = MarriedKeyChain.builder() .random(new SecureRandom()) .followingKeys(partnerKey) .threshold(2).build(); myWallet.addAndActivateHDChain(chain); myAddress = myWallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS); Wallet wallet1 = roundTrip(myWallet); assertEquals(0, wallet1.getTransactions(true).size()); assertEquals(Coin.ZERO, wallet1.getBalance()); assertEquals(2, wallet1.getActiveKeyChain().getSigsRequiredToSpend()); assertEquals(myAddress, wallet1.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS)); }
@Test public void bloom2() throws Exception { // Verify that if when we watch a key, the filter contains at least 100 keys. DeterministicKey[] keys = new DeterministicKey[100]; for (int i = 0; i < keys.length; i++) keys[i] = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS); chain = DeterministicKeyChain.watch(chain.getWatchingKey().dropPrivateBytes().dropParent()); int e = chain.numBloomFilterEntries(); BloomFilter filter = chain.getFilter(e, 0.001, 1); for (DeterministicKey key : keys) assertTrue("key " + key, filter.contains(key.getPubKeyHash())); }