aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r--internal/ethapi/api.go36
1 files changed, 11 insertions, 25 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 0775749e7..8d1a6f746 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -54,7 +54,7 @@ type PublicEthereumAPI struct {
b Backend
}
-// NewPublicEthereumAPI creates a new Etheruem protocol API.
+// NewPublicEthereumAPI creates a new Ethereum protocol API.
func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI {
return &PublicEthereumAPI{b}
}
@@ -448,7 +448,7 @@ type PublicBlockChainAPI struct {
b Backend
}
-// NewPublicBlockChainAPI creates a new Etheruem blockchain API.
+// NewPublicBlockChainAPI creates a new Ethereum blockchain API.
func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI {
return &PublicBlockChainAPI{b}
}
@@ -1081,7 +1081,10 @@ func submitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c
}
if tx.To() == nil {
signer := types.MakeSigner(b.ChainConfig(), b.CurrentBlock().Number())
- from, _ := types.Sender(signer, tx)
+ from, err := types.Sender(signer, tx)
+ if err != nil {
+ return common.Hash{}, err
+ }
addr := crypto.CreateAddress(from, tx.Nonce())
log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
} else {
@@ -1129,29 +1132,12 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
// SendRawTransaction will add the signed transaction to the transaction pool.
// The sender is responsible for signing the transaction and using the correct nonce.
-func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (string, error) {
+func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
tx := new(types.Transaction)
if err := rlp.DecodeBytes(encodedTx, tx); err != nil {
- return "", err
- }
-
- if err := s.b.SendTx(ctx, tx); err != nil {
- return "", err
- }
-
- signer := types.MakeSigner(s.b.ChainConfig(), s.b.CurrentBlock().Number())
- if tx.To() == nil {
- from, err := types.Sender(signer, tx)
- if err != nil {
- return "", err
- }
- addr := crypto.CreateAddress(from, tx.Nonce())
- log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
- } else {
- log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To())
+ return common.Hash{}, err
}
-
- return tx.Hash().Hex(), nil
+ return submitTransaction(ctx, s.b, tx)
}
// Sign calculates an ECDSA signature for:
@@ -1275,7 +1261,7 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr
return common.Hash{}, fmt.Errorf("Transaction %#x not found", matchTx.Hash())
}
-// PublicDebugAPI is the collection of Etheruem APIs exposed over the public
+// PublicDebugAPI is the collection of Ethereum APIs exposed over the public
// debugging endpoint.
type PublicDebugAPI struct {
b Backend
@@ -1318,7 +1304,7 @@ func (api *PublicDebugAPI) SeedHash(ctx context.Context, number uint64) (string,
return fmt.Sprintf("0x%x", ethash.SeedHash(number)), nil
}
-// PrivateDebugAPI is the collection of Etheruem APIs exposed over the private
+// PrivateDebugAPI is the collection of Ethereum APIs exposed over the private
// debugging endpoint.
type PrivateDebugAPI struct {
b Backend