|
@@ -137,6 +137,9 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|
|
// MethodById looks up a method by the 4-byte id
|
|
// MethodById looks up a method by the 4-byte id
|
|
|
// returns nil if none found
|
|
// returns nil if none found
|
|
|
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
|
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
|
|
|
|
+ if len(sigdata) < 4 {
|
|
|
|
|
+ return nil, fmt.Errorf("data too short (% bytes) for abi method lookup", len(sigdata))
|
|
|
|
|
+ }
|
|
|
for _, method := range abi.Methods {
|
|
for _, method := range abi.Methods {
|
|
|
if bytes.Equal(method.Id(), sigdata[:4]) {
|
|
if bytes.Equal(method.Id(), sigdata[:4]) {
|
|
|
return &method, nil
|
|
return &method, nil
|