2020-08-11 21:09:30 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-09-26 21:01:11 +00:00
|
|
|
"fmt"
|
2020-08-11 21:09:30 +00:00
|
|
|
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
|
|
|
)
|
|
|
|
|
2020-09-26 21:01:11 +00:00
|
|
|
// SendRawTransaction send a raw transaction
|
2020-08-11 21:09:30 +00:00
|
|
|
func (api *APIImpl) SendRawTransaction(_ context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
|
2020-09-26 21:01:11 +00:00
|
|
|
if api.ethBackend == nil {
|
|
|
|
// We're running in --chaindata mode or otherwise cannot get the backend
|
|
|
|
return common.Hash{}, fmt.Errorf(NotAvailableChainData, "eth_sendRawTransaction")
|
|
|
|
}
|
2020-08-12 13:47:59 +00:00
|
|
|
res, err := api.ethBackend.AddLocal(encodedTx)
|
2020-08-11 21:09:30 +00:00
|
|
|
return common.BytesToHash(res), err
|
|
|
|
}
|