rpc: fix blockheader marshalling in getblockheader RPC server

Problem: wrong json marshalling of `nextconsensus` field of
result.Header

Solution: change field type from util.uint160 to address string
This commit is contained in:
Anna Shaleva 2020-03-18 12:21:16 +03:00
parent 751e79d480
commit 79f7862496
2 changed files with 4 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core"
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/util"
)
@ -22,7 +23,7 @@ type (
Timestamp uint32 `json:"time"`
Index uint32 `json:"index"`
Nonce string `json:"nonce"`
NextConsensus util.Uint160 `json:"nextconsensus"`
NextConsensus string `json:"nextconsensus"`
Script transaction.Witness `json:"script"`
Confirmations uint32 `json:"confirmations"`
NextBlockHash *util.Uint256 `json:"nextblockhash,omitempty"`
@ -40,7 +41,7 @@ func NewHeader(h *block.Header, chain core.Blockchainer) Header {
Timestamp: h.Timestamp,
Index: h.Index,
Nonce: strconv.FormatUint(h.ConsensusData, 16),
NextConsensus: h.NextConsensus,
NextConsensus: address.Uint160ToString(h.NextConsensus),
Script: h.Script,
Confirmations: chain.BlockHeight() - h.Index + 1,
}

View file

@ -441,7 +441,7 @@ var rpcTestCases = map[string][]rpcTestCase{
Timestamp: header.Timestamp,
Index: header.Index,
Nonce: strconv.FormatUint(header.ConsensusData, 16),
NextConsensus: header.NextConsensus,
NextConsensus: address.Uint160ToString(header.NextConsensus),
Script: header.Script,
Confirmations: e.chain.BlockHeight() - header.Index + 1,
}