feat(daemon): add depth/orphan/reward to getblockheaderbyhash
Matches the C++ daemon's 11-field block header format for hash lookups. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
530750ad3b
commit
8df8ec0a1f
1 changed files with 10 additions and 1 deletions
|
|
@ -597,16 +597,25 @@ func (s *Server) rpcGetBlockHeaderByHash(w http.ResponseWriter, req jsonRPCReque
|
|||
return
|
||||
}
|
||||
|
||||
topHeight, _ := s.chain.Height()
|
||||
blockDepth := uint64(0)
|
||||
if topHeight > meta.Height {
|
||||
blockDepth = topHeight - meta.Height - 1
|
||||
}
|
||||
|
||||
writeResult(w, req.ID, map[string]interface{}{
|
||||
"block_header": map[string]interface{}{
|
||||
"hash": meta.Hash.String(),
|
||||
"height": meta.Height,
|
||||
"timestamp": blk.Timestamp,
|
||||
"difficulty": core.Sprintf("%d", meta.Difficulty),
|
||||
"difficulty": meta.Difficulty,
|
||||
"major_version": blk.MajorVersion,
|
||||
"minor_version": blk.MinorVersion,
|
||||
"nonce": blk.Nonce,
|
||||
"prev_hash": blk.PrevID.String(),
|
||||
"depth": blockDepth,
|
||||
"orphan_status": false,
|
||||
"reward": config.Coin,
|
||||
},
|
||||
"status": "OK",
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue