diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index ecc26827..8beebaa5 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -25,7 +25,7 @@ type GetBlockHeaderVerboseResult struct { Version int32 `json:"version"` VersionHex string `json:"versionHex"` MerkleRoot string `json:"merkleroot"` - ClaimTrie string `json:"claimtrie"` + ClaimTrie string `json:"claimtrie,omitempty"` Time int64 `json:"time"` Nonce uint64 `json:"nonce"` Bits string `json:"bits"` @@ -82,14 +82,14 @@ type GetBlockVerboseResult struct { Version int32 `json:"version"` VersionHex string `json:"versionHex"` MerkleRoot string `json:"merkleroot"` - ClaimTrie string `json:"claimTrie"` + ClaimTrie string `json:"claimTrie,omitempty"` Tx []string `json:"tx,omitempty"` RawTx []TxRawResult `json:"rawtx,omitempty"` // Note: this field is always empty when verbose != 2. Time int64 `json:"time"` Nonce uint32 `json:"nonce"` Bits string `json:"bits"` Difficulty float64 `json:"difficulty"` - PreviousHash string `json:"previousblockhash"` + PreviousHash string `json:"previousblockhash,omitempty"` NextHash string `json:"nextblockhash,omitempty"` } diff --git a/rpcserver.go b/rpcserver.go index f337668a..2438f121 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1188,12 +1188,16 @@ func handleGetBlock(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i params := s.cfg.ChainParams blockHeader := &blk.MsgBlock().Header + var prevHashString string + if blockHeight > 0 { + prevHashString = blockHeader.PrevBlock.String() + } blockReply := btcjson.GetBlockVerboseResult{ Hash: c.Hash, Version: blockHeader.Version, VersionHex: fmt.Sprintf("%08x", blockHeader.Version), MerkleRoot: blockHeader.MerkleRoot.String(), - PreviousHash: blockHeader.PrevBlock.String(), + PreviousHash: prevHashString, Nonce: blockHeader.Nonce, Time: blockHeader.Timestamp.Unix(), Confirmations: int64(1 + best.Height - blockHeight), @@ -1204,6 +1208,7 @@ func handleGetBlock(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i Bits: strconv.FormatInt(int64(blockHeader.Bits), 16), Difficulty: getDifficultyRatio(blockHeader.Bits, params), NextHash: nextHashString, + ClaimTrie: blockHeader.ClaimTrie.String(), } if *c.Verbosity == 1 {