use of com.hederahashgraph.api.proto.java.FileCreateTransactionBody in project hedera-services by hashgraph.
the class HapiFileCreate method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
if (!immutable) {
generateWaclKey(spec);
}
if (contentsPathFn.isPresent()) {
var loc = contentsPathFn.get().apply(spec);
contents = Optional.of(Files.toByteArray(new File(loc)));
}
FileCreateTransactionBody opBody = spec.txns().<FileCreateTransactionBody, FileCreateTransactionBody.Builder>body(FileCreateTransactionBody.class, builder -> {
if (!immutable) {
builder.setKeys(waclKey.getKeyList());
}
memo.ifPresent(builder::setMemo);
contents.ifPresent(b -> builder.setContents(ByteString.copyFrom(b)));
lifetime.ifPresent(s -> builder.setExpirationTime(TxnFactory.expiryGiven(s)));
expiry.ifPresent(t -> builder.setExpirationTime(Timestamp.newBuilder().setSeconds(t).build()));
});
return b -> {
expiryUsed.set(opBody.getExpirationTime());
b.setFileCreate(opBody);
};
}
use of com.hederahashgraph.api.proto.java.FileCreateTransactionBody in project hedera-services by hashgraph.
the class RequestBuilder method getFileCreateBuilder.
/**
* Builds a file create transaction
*
* @param payerAccountNum
* payer account number
* @param payerRealmNum
* payer realm number
* @param payerShardNum
* payer shard number
* @param nodeAccountNum
* node account number
* @param nodeRealmNum
* node realm number
* @param nodeShardNum
* node shard number
* @param transactionFee
* transaction fee
* @param timestamp
* timestamp
* @param transactionDuration
* transaction duration
* @param generateRecord
* generate record boolean
* @param memo
* memo
* @param fileData
* content of the file
* @param fileExpirationTime
* expiration for the file
* @param waclKeyList
* WACL keys
* @return transaction for file create
*/
public static Transaction getFileCreateBuilder(Long payerAccountNum, Long payerRealmNum, Long payerShardNum, Long nodeAccountNum, Long nodeRealmNum, Long nodeShardNum, long transactionFee, Timestamp timestamp, Duration transactionDuration, boolean generateRecord, String memo, ByteString fileData, Timestamp fileExpirationTime, List<Key> waclKeyList) {
FileCreateTransactionBody fileCreateTransactionBody = FileCreateTransactionBody.newBuilder().setExpirationTime(fileExpirationTime).setKeys(KeyList.newBuilder().addAllKeys(waclKeyList).build()).setContents(fileData).build();
TransactionBody.Builder body = getTransactionBody(payerAccountNum, payerRealmNum, payerShardNum, nodeAccountNum, nodeRealmNum, nodeShardNum, transactionFee, timestamp, transactionDuration, generateRecord, memo);
body.setFileCreate(fileCreateTransactionBody);
byte[] bodyBytesArr = body.build().toByteArray();
ByteString bodyBytes = ByteString.copyFrom(bodyBytesArr);
return Transaction.newBuilder().setBodyBytes(bodyBytes).build();
}
Aggregations