use of com.hederahashgraph.api.proto.java.SignedTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method getsCorrectLoggableFormWithSignedTransactionBytes.
@Test
void getsCorrectLoggableFormWithSignedTransactionBytes() throws Exception {
SignedTransaction signedTxn = SignedTransaction.newBuilder().setBodyBytes(someTxn.toByteString()).setSigMap(SignatureMap.newBuilder().addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(ByteString.copyFrom("UNREAL".getBytes())).setEd25519(ByteString.copyFrom("FAKE".getBytes())).build())).build();
Transaction txn = Transaction.newBuilder().setSignedTransactionBytes(signedTxn.toByteString()).build();
SwirldTransaction platformTxn = new SwirldTransaction(txn.toByteArray());
// when:
PlatformTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
Transaction signedTxn4Log = subject.getSignedTxnWrapper();
ByteString signedTxnBytes = signedTxn4Log.getSignedTransactionBytes();
Transaction asBodyBytes = signedTxn4Log.toBuilder().setSignedTransactionBytes(CommonUtils.extractTransactionBodyByteString(signedTxn4Log)).build();
// then:
assertEquals(signedTxnBytes, txn.getSignedTransactionBytes());
assertEquals(signedTxn.getBodyBytes(), asBodyBytes.getSignedTransactionBytes());
}
use of com.hederahashgraph.api.proto.java.SignedTransaction in project hedera-services by hashgraph.
the class HapiSpecOperation method finalizedTxnFromTxnWithBodyBytesAndSigMap.
private Transaction finalizedTxnFromTxnWithBodyBytesAndSigMap(Transaction txnWithBodyBytesAndSigMap) throws Throwable {
if (asTxnWithOnlySigMap) {
return txnWithBodyBytesAndSigMap.toBuilder().clearBodyBytes().build();
}
if (alwaysWithLegacyProtoStructure) {
return txnWithBodyBytesAndSigMap;
}
ByteString bodyByteString = CommonUtils.extractTransactionBodyByteString(txnWithBodyBytesAndSigMap);
SignatureMap sigMap = CommonUtils.extractSignatureMap(txnWithBodyBytesAndSigMap);
SignedTransaction signedTransaction = SignedTransaction.newBuilder().setBodyBytes(bodyByteString).setSigMap(sigMap).build();
Transaction.Builder txnWithSignedTxnBytesBuilder = Transaction.newBuilder().setSignedTransactionBytes(signedTransaction.toByteString());
if (asTxnWithSignedTxnBytesAndSigMap) {
return txnWithSignedTxnBytesBuilder.setSigMap(sigMap).build();
}
if (asTxnWithSignedTxnBytesAndBodyBytes) {
return txnWithSignedTxnBytesBuilder.setBodyBytes(bodyByteString).build();
}
if (txnProtoStructure == HapiSpecSetup.TxnProtoStructure.OLD) {
return txnWithBodyBytesAndSigMap;
}
return txnWithSignedTxnBytesBuilder.build();
}
use of com.hederahashgraph.api.proto.java.SignedTransaction in project hedera-mirror-node by hashgraph.
the class RecordFileParserTest method recordItem.
private RecordItem recordItem(long timestamp) {
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().build();
TransactionBody transactionBody = TransactionBody.newBuilder().setCryptoTransfer(cryptoTransfer).build();
SignedTransaction signedTransaction = SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(SignatureMap.newBuilder().build()).build();
Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(signedTransaction.toByteString()).build();
TransactionRecord transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setNanos((int) timestamp)).build();
return new RecordItem(transaction, transactionRecord);
}
use of com.hederahashgraph.api.proto.java.SignedTransaction in project hedera-mirror-node by hashgraph.
the class RecordFileParserTest method cryptoTransferRecordItem.
private RecordItem cryptoTransferRecordItem(long timestamp) {
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().build();
TransactionBody transactionBody = TransactionBody.newBuilder().setCryptoTransfer(cryptoTransfer).build();
TransactionRecord transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setNanos((int) timestamp)).build();
SignedTransaction signedTransaction = SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(SignatureMap.newBuilder().build()).build();
Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(signedTransaction.toByteString()).build();
return RecordItem.builder().record(transactionRecord).transactionBytes(transaction.toByteArray()).build();
}
Aggregations