guerrerocarlos / bitcoin-miner

Super-slow yet very educative Bitcoin miner in Javascript/NodeJS
MIT License
257 stars 38 forks source link

Nonce out of Range #7

Closed toco3DevTobias closed 10 months ago

toco3DevTobias commented 10 months ago

When the given nonce is >2,147,483,647 (max integer) thetimeBitsNonceBuffer.writeInt32LE(nonce, 8) is value is out of range.

Since you can not mix little endians 32-bit and 64-bit - another workaround is required.

The miners will iterate through all 32-bit values, so they have 4,294,967,296 tries.

Any idea to fix timeBitsNonceBuffer.writeInt32LE(nonce, 8) that max range is allowed to 4,294,967,296.

The implemented algorithm is still working fine - I validated the latest 20 blocks correctly (where the nonce was < 2,147,483,647).

toco3DevTobias commented 10 months ago

The .writeInt32LE function has additional arguments. One of them is noAsssert. Set it to true then it works