Skip to content

Commit dcdb6fe

Browse files
committed
Fix TTN genesis block nonce
1 parent ac37832 commit dcdb6fe

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

genesis.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,18 @@ var teraTestNetGenesisBlock = wire.MsgBlock{
148148
MerkleRoot: testNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
149149
Timestamp: time.Unix(1755606836, 0), // 2025-08-19T08:33:56 +0000 UTC
150150
Bits: 0x207fffff, // Easy difficulty for test network
151-
Nonce: 0x00000002, // Nonce value that produces a block hash meeting the proof-of-work requirement for 0x207fffff difficulty
151+
Nonce: 0x00000005, // Nonce value that produces a block hash meeting the proof-of-work requirement for 0x207fffff difficulty
152152
},
153153
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
154154
}
155155

156156
// teraTestNetGenesisHash is the hash of the first block in the blockchain for the
157157
// tera test network.
158158
var teraTestNetGenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy.
159-
0x5c, 0xce, 0x10, 0x0b, 0x1e, 0x5e, 0xdf, 0x9a,
160-
0x24, 0x22, 0x6f, 0x6a, 0x75, 0x50, 0x18, 0x2c,
161-
0xd3, 0xe8, 0xb9, 0x58, 0x65, 0x98, 0xcc, 0xa2,
162-
0xf9, 0x43, 0xa4, 0x09, 0x32, 0x4b, 0xa0, 0xef,
159+
0xb3, 0x63, 0x94, 0x9e, 0x6a, 0x54, 0xc6, 0x83,
160+
0x97, 0x02, 0x56, 0x65, 0x30, 0x53, 0x01, 0x56,
161+
0x28, 0xac, 0x62, 0xc3, 0x8d, 0xdc, 0x3b, 0xe0,
162+
0x3d, 0x3d, 0x49, 0xbf, 0xe6, 0xbf, 0x38, 0x42,
163163
})
164164

165165
// stnGenesisHash is the hash of the first block in the blockchain for the

genesis_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ var teraTestNetGenesisBlockBytes = []byte{
318318
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |................| */
319319
0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |....;...z{..z.,>| */
320320
0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |gv.a......Q2:...| */
321-
0x4b, 0x1e, 0x5e, 0x4a, 0x34, 0x6f, 0xa4, 0x68, 0xff, 0xff, 0x7f, 0x20, 0x02, 0x00, 0x00, 0x00, /* |K.^J4o.h... ....| */
321+
0x4b, 0x1e, 0x5e, 0x4a, 0x34, 0x6f, 0xa4, 0x68, 0xff, 0xff, 0x7f, 0x20, 0x05, 0x00, 0x00, 0x00, /* |K.^J4o.h... ....| */
322322
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |................| */
323323
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |................| */
324324
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..........M.....| */
@@ -345,24 +345,25 @@ func TestTeraTestNetGenesisProofOfWork(t *testing.T) {
345345

346346
// Get the target from bits
347347
bits := genesisBlock.Header.Bits
348-
mantissa := bits & 0x00ffffff
349348
exponent := bits >> 24
349+
mantissa := bits & 0x007fffff
350350

351351
target := new(big.Int).SetInt64(int64(mantissa))
352352
if exponent > 3 {
353353
target.Lsh(target, 8*(uint(exponent)-3))
354354
}
355355

356356
// Check if hash meets difficulty
357-
hashInt := new(big.Int).SetBytes(hash.CloneBytes())
357+
bn := big.NewInt(0)
358+
bn.SetBytes(bt.ReverseBytes(hash[:]))
358359

359-
if hashInt.Cmp(target) > 0 {
360+
if bn.Cmp(target) > 0 {
360361
t.Fatalf("TestTeraTestNetGenesisProofOfWork: Genesis block does not meet difficulty requirement. "+
361362
"Hash: %s, Target: %064x", hash, target.Bytes())
362363
}
363364

364365
// Verify the nonce is the expected value
365-
expectedNonce := uint32(0x00000002)
366+
expectedNonce := uint32(0x00000005)
366367
if genesisBlock.Header.Nonce != expectedNonce {
367368
t.Fatalf("TestTeraTestNetGenesisProofOfWork: Unexpected nonce - got %d, want %d",
368369
genesisBlock.Header.Nonce, expectedNonce)

0 commit comments

Comments
 (0)