internal/ethapi: support both input and data for personal_sendTransaction (#23476)

Currently, setDefaults overwrites the transaction input value if only input is provided. This causes personal_sendTransaction to estimate the gas based on a transaction with empty data. eth_estimateGas never calls setDefaults so it was unaffected by this.
This commit is contained in:
lightclient 2021-08-27 06:11:15 -06:00 committed by GitHub
parent 62ad17fb00
commit ffae2043f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -146,6 +146,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
if args.Gas == nil { if args.Gas == nil {
// These fields are immutable during the estimation, safe to // These fields are immutable during the estimation, safe to
// pass the pointer directly. // pass the pointer directly.
data := args.data()
callArgs := TransactionArgs{ callArgs := TransactionArgs{
From: args.From, From: args.From,
To: args.To, To: args.To,
@ -153,7 +154,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
MaxFeePerGas: args.MaxFeePerGas, MaxFeePerGas: args.MaxFeePerGas,
MaxPriorityFeePerGas: args.MaxPriorityFeePerGas, MaxPriorityFeePerGas: args.MaxPriorityFeePerGas,
Value: args.Value, Value: args.Value,
Data: args.Data, Data: (*hexutil.Bytes)(&data),
AccessList: args.AccessList, AccessList: args.AccessList,
} }
pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber) pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)