Search in sources :

Example 1 with TransactionAdapter

use of org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter.TransactionAdapter in project besu by hyperledger.

the class GraphQLDataFetchers method updatePrivatePayload.

private TransactionAdapter updatePrivatePayload(final Transaction transaction) {
    final GoQuorumEnclave enclave = goQuorumPrivacyParameters.get().enclave();
    Bytes enclavePayload;
    try {
        // Retrieve the payload from the enclave
        enclavePayload = Bytes.wrap(enclave.receive(transaction.getPayload().toBase64String()).getPayload());
    } catch (final Exception ex) {
        LOG.debug("An error occurred while retrieving the GoQuorum transaction payload: ", ex);
        enclavePayload = Bytes.EMPTY;
    }
    // Return a new transaction containing the retrieved payload
    return new TransactionAdapter(new TransactionWithMetadata(new Transaction(transaction.getNonce(), transaction.getGasPrice(), transaction.getMaxPriorityFeePerGas(), transaction.getMaxFeePerGas(), transaction.getGasLimit(), transaction.getTo(), transaction.getValue(), transaction.getSignature(), enclavePayload, transaction.getSender(), transaction.getChainId(), Optional.ofNullable(transaction.getV()))));
}
Also used : GoQuorumEnclave(org.hyperledger.besu.enclave.GoQuorumEnclave) Bytes(org.apache.tuweni.bytes.Bytes) Transaction(org.hyperledger.besu.ethereum.core.Transaction) TransactionWithMetadata(org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata) TransactionAdapter(org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter.TransactionAdapter) RLPException(org.hyperledger.besu.ethereum.rlp.RLPException)

Example 2 with TransactionAdapter

use of org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter.TransactionAdapter in project besu by hyperledger.

the class GraphQLDataFetchers method getTransactionAdapter.

private TransactionAdapter getTransactionAdapter(final TransactionWithMetadata transactionWithMetadata) {
    final Transaction transaction = transactionWithMetadata.getTransaction();
    final boolean isGoQuorumCompatbilityMode = goQuorumPrivacyParameters.isPresent();
    final boolean isGoQuorumPrivateTransaction = isGoQuorumCompatbilityMode && transaction.isGoQuorumPrivateTransaction(isGoQuorumCompatbilityMode);
    return isGoQuorumPrivateTransaction ? updatePrivatePayload(transaction) : new TransactionAdapter(transactionWithMetadata);
}
Also used : Transaction(org.hyperledger.besu.ethereum.core.Transaction) TransactionAdapter(org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter.TransactionAdapter)

Aggregations

TransactionAdapter (org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter.TransactionAdapter)2 Transaction (org.hyperledger.besu.ethereum.core.Transaction)2 Bytes (org.apache.tuweni.bytes.Bytes)1 GoQuorumEnclave (org.hyperledger.besu.enclave.GoQuorumEnclave)1 TransactionWithMetadata (org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata)1 RLPException (org.hyperledger.besu.ethereum.rlp.RLPException)1