Search in sources :

Example 1 with SignedTransaction

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());
}
Also used : SwirldTransaction(com.swirlds.common.SwirldTransaction) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SwirldTransaction(com.swirlds.common.SwirldTransaction) ByteString(com.google.protobuf.ByteString) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) Test(org.junit.jupiter.api.Test)

Example 2 with SignedTransaction

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();
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) ByteString(com.google.protobuf.ByteString) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap)

Example 3 with SignedTransaction

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);
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)

Example 4 with SignedTransaction

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();
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)

Aggregations

SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)4 Transaction (com.hederahashgraph.api.proto.java.Transaction)4 ByteString (com.google.protobuf.ByteString)2 CryptoTransferTransactionBody (com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)2 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)2 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)2 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)1 SignatureMap (com.hederahashgraph.api.proto.java.SignatureMap)1 SwirldTransaction (com.swirlds.common.SwirldTransaction)1 Test (org.junit.jupiter.api.Test)1