Skip to content

Commit

Permalink
ethapi: prevent creating contract if no data is provided (ethereum#16108
Browse files Browse the repository at this point in the history
)

* ethapi: prevent creating contract if no data is provided

* internal/ethapi: downcase error for no data on contract creation
  • Loading branch information
holiman authored and karalabe committed Feb 21, 2018
1 parent 14c7637 commit b585f76
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,18 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
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.`)
}
if args.To == nil {
// Contract creation
var input []byte
if args.Data != nil {
input = *args.Data
} else if args.Input != nil {
input = *args.Input
}
if len(input) == 0 {
return errors.New(`contract creation without any data provided`)
}
}
return nil
}

Expand Down

0 comments on commit b585f76

Please sign in to comment.