feat(daemon): add depth/orphan/reward to getblockheaderbyhash
Some checks failed
Security Scan / security (push) Successful in 13s
Test / Test (push) Failing after 37s

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:
Claude 2026-04-02 05:41:48 +01:00
parent 530750ad3b
commit 8df8ec0a1f
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -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",
})