diff options
author | Martin Holst Swende <martin@swende.se> | 2018-02-21 22:10:18 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-02-21 22:10:18 +0800 |
commit | b585f761283957dcd1783a134449a01423145df3 (patch) | |
tree | a830c3a68a4bb43ba8e00e1989d5dd94d229ad4f /internal/ethapi/api.go | |
parent | 14c76371bab105a99c796a652df86df3e3e7d958 (diff) | |
download | dexon-b585f761283957dcd1783a134449a01423145df3.tar dexon-b585f761283957dcd1783a134449a01423145df3.tar.gz dexon-b585f761283957dcd1783a134449a01423145df3.tar.bz2 dexon-b585f761283957dcd1783a134449a01423145df3.tar.lz dexon-b585f761283957dcd1783a134449a01423145df3.tar.xz dexon-b585f761283957dcd1783a134449a01423145df3.tar.zst dexon-b585f761283957dcd1783a134449a01423145df3.zip |
ethapi: prevent creating contract if no data is provided (#16108)
* ethapi: prevent creating contract if no data is provided
* internal/ethapi: downcase error for no data on contract creation
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r-- | internal/ethapi/api.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 314086335..636d0bfe2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -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 } |