address: check for prefix when decoding

This commit is contained in:
Roman Khimov 2019-12-25 15:50:52 +03:00
parent 89b6cbf795
commit c5ceb9128a

View file

@ -1,6 +1,8 @@
package address package address
import ( import (
"errors"
"github.com/CityOfZion/neo-go/pkg/encoding/base58" "github.com/CityOfZion/neo-go/pkg/encoding/base58"
"github.com/CityOfZion/neo-go/pkg/util" "github.com/CityOfZion/neo-go/pkg/util"
) )
@ -23,5 +25,8 @@ func DecodeUint160(s string) (u util.Uint160, err error) {
if err != nil { if err != nil {
return u, err return u, err
} }
if b[0] != Prefix {
return u, errors.New("wrong address prefix")
}
return util.Uint160DecodeBytesBE(b[1:21]) return util.Uint160DecodeBytesBE(b[1:21])
} }