From 3c13c8b7a58cd38b1d301df33e4f0cce65be9c01 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 10 Nov 2021 14:31:13 +0300 Subject: [PATCH] rpc: refactor GetUint160FromHex helper We can trim prefix using `strings` library like it is done for uint256. --- pkg/rpc/request/param.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/rpc/request/param.go b/pkg/rpc/request/param.go index 78fc8b08a..77bef2e85 100644 --- a/pkg/rpc/request/param.go +++ b/pkg/rpc/request/param.go @@ -306,11 +306,8 @@ func (p *Param) GetUint160FromHex() (util.Uint160, error) { if err != nil { return util.Uint160{}, err } - if len(s) == 2*util.Uint160Size+2 && s[0] == '0' && s[1] == 'x' { - s = s[2:] - } - return util.Uint160DecodeStringLE(s) + return util.Uint160DecodeStringLE(strings.TrimPrefix(s, "0x")) } // GetUint160FromAddress returns Uint160 value of the parameter that was