/** * <code>optional .com.openwallet.core.protos.Key seed = 2;</code> */ public Builder setSeed( com.openwallet.core.protos.Protos.Key.Builder builderForValue) { if (seedBuilder_ == null) { seed_ = builderForValue.build(); onChanged(); } else { seedBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000002; return this; } /**
subBuilder.mergeFrom(seed_); seed_ = subBuilder.buildPartial(); subBuilder.mergeFrom(masterKey_); masterKey_ = subBuilder.buildPartial();
/** * <code>optional .com.openwallet.core.protos.DeterministicKey deterministic_key = 6;</code> */ private com.google.protobuf.SingleFieldBuilder< com.openwallet.core.protos.Protos.DeterministicKey, com.openwallet.core.protos.Protos.DeterministicKey.Builder, com.openwallet.core.protos.Protos.DeterministicKeyOrBuilder> getDeterministicKeyFieldBuilder() { if (deterministicKeyBuilder_ == null) { deterministicKeyBuilder_ = new com.google.protobuf.SingleFieldBuilder< com.openwallet.core.protos.Protos.DeterministicKey, com.openwallet.core.protos.Protos.DeterministicKey.Builder, com.openwallet.core.protos.Protos.DeterministicKeyOrBuilder>( getDeterministicKey(), getParentForChildren(), isClean()); deterministicKey_ = null; } return deterministicKeyBuilder_; }
DeterministicKey key = (DeterministicKey) entry.getKey(); Protos.Key.Builder proto = entry.getValue(); proto.setType(Protos.Key.Type.DETERMINISTIC_KEY); final Protos.DeterministicKey.Builder detKey = proto.getDeterministicKeyBuilder(); detKey.setChainCode(ByteString.copyFrom(key.getChainCode())); for (ChildNumber num : key.getPath())
public static Protos.Key.Builder serializeEncryptableItem(EncryptableItem item) { Protos.Key.Builder proto = Protos.Key.newBuilder(); if (item.isEncrypted() && item.getEncryptedData() != null) { // The encrypted data can be missing for an "encrypted" key in the case of a deterministic wallet for // which the leaf keys chain to an encrypted parent and rederive their private keys on the fly. In that // case the caller in DeterministicKeyChain will take care of setting the type. EncryptedData data = item.getEncryptedData(); proto.getEncryptedDataBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(data.encryptedBytes)) .setInitialisationVector(ByteString.copyFrom(data.initialisationVector)); // We don't allow mixing of encryption types at the moment. checkState(item.getEncryptionType() == org.bitcoinj.wallet.Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES, "We don't allow mixing of encryption types at the moment"); proto.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { final byte[] secret = item.getSecretBytes(); // The secret might be missing in the case of a watching wallet, or a key for which the private key // is expected to be rederived on the fly from its parent. if (secret != null) proto.setSecretBytes(ByteString.copyFrom(secret)); proto.setType(Protos.Key.Type.ORIGINAL); } return proto; }
/** * <code>optional .com.openwallet.core.protos.Key seed = 2;</code> */ public Builder mergeSeed(com.openwallet.core.protos.Protos.Key value) { if (seedBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002) && seed_ != com.openwallet.core.protos.Protos.Key.getDefaultInstance()) { seed_ = com.openwallet.core.protos.Protos.Key.newBuilder(seed_).mergeFrom(value).buildPartial(); } else { seed_ = value; } onChanged(); } else { seedBuilder_.mergeFrom(value); } bitField0_ |= 0x00000002; return this; } /**
/** * <code>required .com.openwallet.core.protos.Key master_key = 3;</code> */ public Builder mergeMasterKey(com.openwallet.core.protos.Protos.Key value) { if (masterKeyBuilder_ == null) { if (((bitField0_ & 0x00000008) == 0x00000008) && masterKey_ != com.openwallet.core.protos.Protos.Key.getDefaultInstance()) { masterKey_ = com.openwallet.core.protos.Protos.Key.newBuilder(masterKey_).mergeFrom(value).buildPartial(); } else { masterKey_ = value; } onChanged(); } else { masterKeyBuilder_.mergeFrom(value); } bitField0_ |= 0x00000008; return this; } /**
/** * <code>optional .com.openwallet.core.protos.EncryptedData encrypted_data = 3;</code> * * <pre> * If the secret data is encrypted, then secret_bytes is missing and this field is set. * </pre> */ private com.google.protobuf.SingleFieldBuilder< com.openwallet.core.protos.Protos.EncryptedData, com.openwallet.core.protos.Protos.EncryptedData.Builder, com.openwallet.core.protos.Protos.EncryptedDataOrBuilder> getEncryptedDataFieldBuilder() { if (encryptedDataBuilder_ == null) { encryptedDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< com.openwallet.core.protos.Protos.EncryptedData, com.openwallet.core.protos.Protos.EncryptedData.Builder, com.openwallet.core.protos.Protos.EncryptedDataOrBuilder>( getEncryptedData(), getParentForChildren(), isClean()); encryptedData_ = null; } return encryptedDataBuilder_; }
List<Protos.Key.Builder> toEditableProtobuf() { LinkedList<Protos.Key.Builder> entries = newLinkedList(); // Entropy Protos.Key.Builder entropyProto = KeyUtils.serializeKey(entropy); entropyProto.setType(Protos.Key.Type.DETERMINISTIC_KEY); final Protos.DeterministicKey.Builder detKey = entropyProto.getDeterministicKeyBuilder(); detKey.setChainCode(ByteString.copyFrom(entropy.getChainCode())); for (ChildNumber num : entropy.getPath()) { detKey.addPath(num.i()); } entries.add(entropyProto); // NTX key Protos.Key.Builder publicKeyProto = Protos.Key.newBuilder(); publicKeyProto.setType(Protos.Key.Type.ORIGINAL); publicKeyProto.setPublicKey(ByteString.copyFrom(publicKey)); entries.add(publicKeyProto); return entries; }
public final boolean isInitialized() { if (!hasType()) { return false; } if (hasEncryptedData()) { if (!getEncryptedData().isInitialized()) { return false; } } if (hasDeterministicKey()) { if (!getDeterministicKey().isInitialized()) { return false; } } return true; }
/** * <code>required .com.openwallet.core.protos.Key master_key = 3;</code> */ public Builder setMasterKey( com.openwallet.core.protos.Protos.Key.Builder builderForValue) { if (masterKeyBuilder_ == null) { masterKey_ = builderForValue.build(); onChanged(); } else { masterKeyBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000008; return this; } /**
/** * <code>repeated .com.openwallet.core.protos.Key key = 3;</code> */ public Builder setKey( int index, com.openwallet.core.protos.Protos.Key.Builder builderForValue) { if (keyBuilder_ == null) { ensureKeyIsMutable(); key_.set(index, builderForValue.build()); onChanged(); } else { keyBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .com.openwallet.core.protos.Key key = 3;</code> */ public Builder addKey( int index, com.openwallet.core.protos.Protos.Key.Builder builderForValue) { if (keyBuilder_ == null) { ensureKeyIsMutable(); key_.add(index, builderForValue.build()); onChanged(); } else { keyBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .com.openwallet.core.protos.Key key = 3;</code> */ public Builder addKey( com.openwallet.core.protos.Protos.Key.Builder builderForValue) { if (keyBuilder_ == null) { ensureKeyIsMutable(); key_.add(builderForValue.build()); onChanged(); } else { keyBuilder_.addMessage(builderForValue.build()); } return this; } /**
private static Builder create() { return new Builder(); }
public Builder clone() { return create().mergeFrom(buildPartial()); }
public com.openwallet.core.protos.Protos.Key build() { com.openwallet.core.protos.Protos.Key result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
List<Protos.Key> toProtobuf() { LinkedList<Protos.Key> entries = newLinkedList(); List<Protos.Key.Builder> protos = toEditableProtobuf(); for (Protos.Key.Builder proto : protos) { entries.add(proto.build()); } return entries; }
/** * <code>optional .com.openwallet.core.protos.DeterministicKey deterministic_key = 6;</code> */ public com.openwallet.core.protos.Protos.DeterministicKey.Builder getDeterministicKeyBuilder() { bitField0_ |= 0x00000020; onChanged(); return getDeterministicKeyFieldBuilder().getBuilder(); } /**