aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-12-18 19:50:21 +0800
committerGitHub <noreply@github.com>2017-12-18 19:50:21 +0800
commit8c33ac10bff32d082facfd274188334a3236a4e7 (patch)
tree505b9b727642636dacc24f43429e559a1b33c7b8 /internal
parent3b79bac05b6a7b9c3845919f274d6014c821ea4c (diff)
downloadgo-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.tar
go-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.tar.gz
go-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.tar.bz2
go-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.tar.lz
go-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.tar.xz
go-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.tar.zst
go-tangerine-8c33ac10bff32d082facfd274188334a3236a4e7.zip
internal/ethapi: support "input" in transaction args (#15640)
The tx data field is called "input" in returned objects and "data" in argument objects. Make it so "input" can be used, but bail if both are set.
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 76a7306e4..d07b2e693 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -17,6 +17,7 @@
package ethapi
import (
+ "bytes"
"context"
"errors"
"fmt"
@@ -1070,8 +1071,11 @@ type SendTxArgs struct {
Gas *hexutil.Big `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
Value *hexutil.Big `json:"value"`
- Data hexutil.Bytes `json:"data"`
Nonce *hexutil.Uint64 `json:"nonce"`
+ // We accept "data" and "input" for backwards-compatibility reasons. "input" is the
+ // newer name and should be preferred by clients.
+ Data *hexutil.Bytes `json:"data"`
+ Input *hexutil.Bytes `json:"input"`
}
// setDefaults is a helper function that fills in default values for unspecified tx fields.
@@ -1096,14 +1100,23 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
}
args.Nonce = (*hexutil.Uint64)(&nonce)
}
+ if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
+ return errors.New(`Both "data" and "input" are set and not equal. Please use "input" to pass transaction call data.`)
+ }
return nil
}
func (args *SendTxArgs) toTransaction() *types.Transaction {
+ var input []byte
+ if args.Data != nil {
+ input = *args.Data
+ } else if args.Input != nil {
+ input = *args.Input
+ }
if args.To == nil {
- return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), (*big.Int)(args.Gas), (*big.Int)(args.GasPrice), args.Data)
+ return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), (*big.Int)(args.Gas), (*big.Int)(args.GasPrice), input)
}
- return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), (*big.Int)(args.Gas), (*big.Int)(args.GasPrice), args.Data)
+ return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), (*big.Int)(args.Gas), (*big.Int)(args.GasPrice), input)
}
// submitTransaction is a helper function that submits tx to txPool and logs a message.