diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 07cbac813..d861c12b4 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -657,7 +657,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ invoke: func(c *Client) (interface{}, error) { return c.GetUnclaimedGas("NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB") }, - serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"address":"NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB","unclaimed":"8972.99680935"}}`, + serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"address":"NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB","unclaimed":"897299680935"}}`, result: func(c *Client) interface{} { addr, err := address.StringToUint160("NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB") if err != nil { diff --git a/pkg/rpc/response/result/unclaimed_gas.go b/pkg/rpc/response/result/unclaimed_gas.go index c8e3183f7..af051acdd 100644 --- a/pkg/rpc/response/result/unclaimed_gas.go +++ b/pkg/rpc/response/result/unclaimed_gas.go @@ -2,11 +2,10 @@ package result import ( "encoding/json" - "fmt" + "errors" "math/big" "github.com/nspcc-dev/neo-go/pkg/encoding/address" - "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/util" ) @@ -26,7 +25,7 @@ type unclaimedGas struct { func (g UnclaimedGas) MarshalJSON() ([]byte, error) { gas := &unclaimedGas{ Address: address.Uint160ToString(g.Address), - Unclaimed: fixedn.ToString(&g.Unclaimed, 8), + Unclaimed: g.Unclaimed.String(), } return json.Marshal(gas) } @@ -37,9 +36,9 @@ func (g *UnclaimedGas) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, gas); err != nil { return err } - uncl, err := fixedn.FromString(gas.Unclaimed, 8) - if err != nil { - return fmt.Errorf("failed to convert unclaimed gas: %w", err) + uncl, ok := new(big.Int).SetString(gas.Unclaimed, 10) + if !ok { + return errors.New("failed to convert unclaimed gas") } g.Unclaimed = *uncl addr, err := address.StringToUint160(gas.Address)