From 3898aadcec10f98df4748cf84137bbd39270d99f Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 6 Dec 2019 19:47:58 +0300 Subject: [PATCH] rpc: simplify uint160 handling Use new Uint160DecodeStringLE() function. --- pkg/rpc/param.go | 6 +----- pkg/rpc/param_test.go | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/rpc/param.go b/pkg/rpc/param.go index ea8001107..7e9f09e66 100644 --- a/pkg/rpc/param.go +++ b/pkg/rpc/param.go @@ -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 diff --git a/pkg/rpc/param_test.go b/pkg/rpc/param_test.go index 28be59dba..3023f2d48 100644 --- a/pkg/rpc/param_test.go +++ b/pkg/rpc/param_test.go @@ -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)