Merge pull request #547 from nspcc-dev/rpc-uint160

rpc: simplify uint160 handling
This commit is contained in:
Roman Khimov 2019-12-09 11:37:37 +03:00 committed by GitHub
commit 1217c4f62a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 7 deletions

View file

@ -85,11 +85,7 @@ func (p Param) GetUint160FromHex() (util.Uint160, error) {
return util.Uint160{}, err
}
scriptHashLE, err := util.Uint160DecodeStringBE(s)
if err != nil {
return util.Uint160{}, err
}
return util.Uint160DecodeBytesBE(scriptHashLE.BytesLE())
return util.Uint160DecodeStringLE(s)
}
// GetUint160FromAddress returns Uint160 value of the parameter that was

View file

@ -112,8 +112,7 @@ func TestParamGetUint256(t *testing.T) {
func TestParamGetUint160FromHex(t *testing.T) {
in := "50befd26fdf6e4d957c11e078b24ebce6291456f"
u160, _ := util.Uint160DecodeStringBE(in)
u160, _ = util.Uint160DecodeBytesBE(util.ArrayReverse(u160[:]))
u160, _ := util.Uint160DecodeStringLE(in)
p := Param{stringT, in}
u, err := p.GetUint160FromHex()
assert.Equal(t, u160, u)