Skip to content

Commit

Permalink
fix: fixed bits
Browse files Browse the repository at this point in the history
  • Loading branch information
pred695 committed Apr 14, 2024
1 parent 391cd6d commit d0b613a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type BlockHeader struct {
prevBlockHash string
merkleRoot string
time int64
bits string
bits uint32
nonce uint32
}

Expand All @@ -21,7 +21,7 @@ var Bh BlockHeader = BlockHeader{
prevBlockHash: "0000000000000000000000000000000000000000000000000000000000000000",
merkleRoot: "",
time: time.Now().Unix(),
bits: "1f00ffff",
bits: 0x1f00ffff,
nonce: 0,
}

Expand Down
2 changes: 1 addition & 1 deletion output.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
07000000000000000000000000000000000000000000000000000000000000000000ff009a8f7b50adf2dcbdbc1a0a5869c954e879fa0daec60e09b20fe7d241760aeb373c2c1c661f00ffffd9ac0000
0700000000000000000000000000000000000000000000000000000000000000000000009a8f7b50adf2dcbdbc1a0a5869c954e879fa0daec60e09b20fe7d241760aeb3799301c66ffff001f10950000
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff02895d8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed3a44995d77b02e34b810da0cb9e5af0ca02aafeed77241c892d7ba23e4779c8b00000000
b73427856b9c9a9f7599a4895f7cf56bb1f2fe5bafb66a9f7788f67245389b7d
6e1b596941749270eadf13d650fdee343b372e63476762709ebbbdb76df9f982
Expand Down
3 changes: 2 additions & 1 deletion pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func SerializeBlockHeader(bh *BlockHeader) []byte {
binary.LittleEndian.PutUint32(timeBytes, uint32(bh.time))
serialized = append(serialized, timeBytes...)

bitsBytes, _ := hex.DecodeString(bh.bits)
bitsBytes := make([]byte, 4)
binary.LittleEndian.PutUint32(bitsBytes, bh.bits)
serialized = append(serialized, bitsBytes...)

nonceBytes := make([]byte, 4)
Expand Down

0 comments on commit d0b613a

Please sign in to comment.