@@ -17,12 +17,12 @@ const (
1717
1818// Header represents a Bitcoin block header (80 bytes)
1919type Header struct {
20- Version int32 `json:"version"` // 4 bytes - Block version
21- PrevBlock chainhash.Hash `json:"prevBlock"` // 32 bytes - Previous block hash
22- MerkleRoot chainhash.Hash `json:"merkleRoot"` // 32 bytes - Merkle root hash
23- Timestamp uint32 `json:"timestamp"` // 4 bytes - Block timestamp (Unix time)
24- Bits uint32 `json:"bits"` // 4 bytes - Difficulty target
25- Nonce uint32 `json:"nonce"` // 4 bytes - Nonce
20+ Version int32 `json:"version"` // 4 bytes - Block version
21+ PrevHash chainhash.Hash `json:"previousHash"` // 32 bytes - Previous block hash
22+ MerkleRoot chainhash.Hash `json:"merkleRoot"` // 32 bytes - Merkle root hash
23+ Timestamp uint32 `json:"time"` // 4 bytes - Block timestamp (Unix time)
24+ Bits uint32 `json:"bits"` // 4 bytes - Difficulty target
25+ Nonce uint32 `json:"nonce"` // 4 bytes - Nonce
2626}
2727
2828// NewHeaderFromBytes creates a BlockHeader from an 80-byte slice
@@ -40,7 +40,7 @@ func NewHeaderFromBytes(data []byte) (*Header, error) {
4040 }
4141
4242 // Read previous block hash (32 bytes)
43- if _ , err := io .ReadFull (r , h .PrevBlock [:]); err != nil {
43+ if _ , err := io .ReadFull (r , h .PrevHash [:]); err != nil {
4444 return nil , fmt .Errorf ("failed to read prev block hash: %w" , err )
4545 }
4646
@@ -85,7 +85,7 @@ func (h *Header) Bytes() []byte {
8585 _ = binary .Write (buf , binary .LittleEndian , h .Version )
8686
8787 // Write previous block hash (32 bytes)
88- buf .Write (h .PrevBlock [:])
88+ buf .Write (h .PrevHash [:])
8989
9090 // Write merkle root (32 bytes)
9191 buf .Write (h .MerkleRoot [:])
@@ -115,5 +115,5 @@ func (h *Header) Hash() chainhash.Hash {
115115// String returns a string representation of the header
116116func (h * Header ) String () string {
117117 return fmt .Sprintf ("Header{Hash: %s, PrevBlock: %s, Height: ?, Bits: %d}" ,
118- h .Hash ().String (), h .PrevBlock .String (), h .Bits )
118+ h .Hash ().String (), h .PrevHash .String (), h .Bits )
119119}
0 commit comments