I'm running a script that selects random historical blocks. For each random block I am passing the correct nonce. Sometimes the hash is correct, sometimes it is not correct and other times there is an error. Here are repeatable samples using the example code...
//
//Target Block: 000000000000000002c098e283d0f186e3f0d591839c875572f8d0d02e08f35a
//Correct nonce will be: 2382794207
//
const block = {
version: 536870912
,previousblockhash: '000000000000000002c91a74eff899976e9738554f51c5673dbb4f4de3764b1f'
,merkleroot: '1ff8c9595b935f4566b0ef28a4304c06e98d4f3074c838a1b87453b23e9728da'
,time: 1485910721
,bits: '1802cc47'
}
TypeError: "value" argument is out of bounds
at checkInt (buffer.js:1185:11)
at Buffer.writeInt32LE (buffer.js:1375:5)
at Miner.getHash (C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin-miner\index.js:56:28)
at miner (C:\Users\corbi\OneDrive\Documents\NodeJS\Miner\index.js:67:21)
at C:\Users\corbi\OneDrive\Documents\NodeJS\Miner\index.js:50:11
at C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin\lib\index.js:37:8
at C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin\lib\jsonrpc.js:138:13
at Array.forEach (<anonymous>)
at IncomingMessage.<anonymous> (C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin\lib\jsonrpc.js:127:15)
at emitNone (events.js:111:20)
buffer.js:405
throw new TypeError('Arguments must be Buffers or Uint8Arrays');
^
TypeError: Arguments must be Buffers or Uint8Arrays
at Function.compare (buffer.js:405:11)
at Miner.checkHash (C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin-miner\index.js:93:17)
at miner (C:\Users\corbi\OneDrive\Documents\NodeJS\Miner\index.js:68:16)
at C:\Users\corbi\OneDrive\Documents\NodeJS\Miner\index.js:50:11
at C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin\lib\index.js:37:8
at C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin\lib\jsonrpc.js:138:13
at Array.forEach (<anonymous>)
at IncomingMessage.<anonymous> (C:\Users\corbi\OneDrive\Documents\NodeJS\node_modules\bitcoin\lib\jsonrpc.js:127:15)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
I'm running a script that selects random historical blocks. For each random block I am passing the correct nonce. Sometimes the hash is correct, sometimes it is not correct and other times there is an error. Here are repeatable samples using the example code...
CORRECT HASH:
INCORRECT HASH:
ERROR (seems to be related to nonce value):