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 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; } /**
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(com.openwallet.core.protos.Protos.Key prototype) {
public static Builder newBuilder(com.openwallet.core.protos.Protos.Key prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }