Search in sources :

Example 6 with ImmutableTransaction

use of org.ethereum.core.ImmutableTransaction in project rskj by rsksmart.

the class EthModuleTransactionBase method sendRawTransaction.

@Override
public String sendRawTransaction(String rawData) {
    String s = null;
    try {
        Transaction tx = new ImmutableTransaction(stringHexToByteArray(rawData));
        if (null == tx.getGasLimit() || null == tx.getGasPrice() || null == tx.getValue()) {
            throw invalidParamError("Missing parameter, gasPrice, gas or value");
        }
        TransactionPoolAddResult result = transactionGateway.receiveTransaction(tx);
        if (!result.transactionsWereAdded()) {
            throw RskJsonRpcRequestException.transactionError(result.getErrorMessage());
        }
        return s = tx.getHash().toJsonString();
    } finally {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("eth_sendRawTransaction({}): {}", rawData, s);
        }
    }
}
Also used : ImmutableTransaction(org.ethereum.core.ImmutableTransaction) Transaction(org.ethereum.core.Transaction) ImmutableTransaction(org.ethereum.core.ImmutableTransaction) TransactionPoolAddResult(org.ethereum.core.TransactionPoolAddResult)

Aggregations

ImmutableTransaction (org.ethereum.core.ImmutableTransaction)6 Transaction (org.ethereum.core.Transaction)6 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 TransactionPoolAddResult (org.ethereum.core.TransactionPoolAddResult)1 ECKey (org.ethereum.crypto.ECKey)1 RLPElement (org.ethereum.util.RLPElement)1 RLPList (org.ethereum.util.RLPList)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Ignore (org.junit.Ignore)1