boolean encrypted = key.getType() == Protos.Key.Type.ENCRYPTED_SCRYPT_AES; byte[] priv = key.hasSecretBytes() ? key.getSecretBytes().toByteArray() : null; if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray();
boolean encrypted = key.getType() == Protos.Key.Type.ENCRYPTED_SCRYPT_AES; byte[] priv = key.hasSecretBytes() ? key.getSecretBytes().toByteArray() : null; if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray();
boolean encrypted = key.getType() == Protos.Key.Type.ENCRYPTED_SCRYPT_AES; byte[] priv = key.hasSecretBytes() ? key.getSecretBytes().toByteArray() : null; if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray();
byte[] pubKey = keyProto.hasPublicKey() ? keyProto.getPublicKey().toByteArray() : null;
mergeEncryptedData(other.getEncryptedData()); if (other.hasPublicKey()) { setPublicKey(other.getPublicKey());
mergeEncryptedData(other.getEncryptedData()); if (other.hasPublicKey()) { setPublicKey(other.getPublicKey());
boolean encrypted = key.getType() == Protos.Key.Type.ENCRYPTED_SCRYPT_AES; byte[] priv = key.hasSecretBytes() ? key.getSecretBytes().toByteArray() : null; if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray();
mergeEncryptedData(other.getEncryptedData()); if (other.hasPublicKey()) { setPublicKey(other.getPublicKey());
mergeEncryptedData(other.getEncryptedData()); if (other.hasPublicKey()) { setPublicKey(other.getPublicKey());
public Builder mergeFrom(org.bitcoinj.wallet.Protos.Key other) { if (other == org.bitcoinj.wallet.Protos.Key.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasPrivateKey()) { setPrivateKey(other.getPrivateKey()); } if (other.hasEncryptedPrivateKey()) { mergeEncryptedPrivateKey(other.getEncryptedPrivateKey()); } if (other.hasPublicKey()) { setPublicKey(other.getPublicKey()); } if (other.hasLabel()) { bitField0_ |= 0x00000010; label_ = other.label_; onChanged(); } if (other.hasCreationTimestamp()) { setCreationTimestamp(other.getCreationTimestamp()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
@Test public void watching() throws UnreadableWalletException { ECKey key1 = new ECKey(); ECKey pub = ECKey.fromPublicOnly(key1.getPubKeyPoint()); chain.importKeys(pub); assertEquals(1, chain.numKeys()); List<Protos.Key> keys = chain.serializeToProtobuf(); assertEquals(1, keys.size()); assertTrue(keys.get(0).hasPublicKey()); assertFalse(keys.get(0).hasSecretBytes()); chain = BasicKeyChain.fromProtobufUnencrypted(keys); assertEquals(1, chain.numKeys()); assertFalse(chain.findKeyFromPubKey(pub.getPubKey()).hasPrivKey()); }