accounts/abi: add another unpack interface

This commit is contained in:
Martin Holst Swende
2017-12-28 11:17:45 +01:00
parent 5603715c06
commit 1ede68355d
5 changed files with 395 additions and 14 deletions

View File

@ -136,11 +136,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
// MethodById looks up a method by the 4-byte id
// returns nil if none found
func (abi *ABI) MethodById(sigdata []byte) *Method {
func (abi *ABI) MethodById(sigdata []byte) (*Method, error){
for _, method := range abi.Methods {
if bytes.Equal(method.Id(), sigdata[:4]) {
return &method
return &method, nil
}
}
return nil
return nil, fmt.Errorf("ABI spec does not contain method signature in data: 0x%x", sigdata[:4])
}