Skip to content

Inconsistent API  #15628

@holiman

Description

@holiman

The API:s are dangerously inconsistent.

Used in eth.sendTransaction:

type SendTxArgs struct {
...
    Data     hexutil.Bytes   `json:"data"`
...
}

And we also have, returned from e.g. getTransaction:

type RPCTransaction struct {
...
    Input            hexutil.Bytes   `json:"input"`
}

Not to mention

type txdata struct {
...
    Payload      []byte          `json:"input"    gencodec:"required"`

In case someone tries to resend a transaction manually by first fetching from the pool, changing the gas, and resubmitting. What the user won't know, is that the data now resides in input, and won't be present in the replacement tx.

This is a disaster waiting to happen.

Suggested fix

We can't do simple renaming, imo.. I'd prefer doing something like this:

  • If we expect data, the user passes input and data is nil, we do X
  • If we expect data, the users passes both input and data, which are not equal, we do Y

And vice versa. Maybe X is convert+warn, and maybe Y is reject+warn.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions