├── .gitignore ├── bundle.js ├── worker.js ├── index2.js ├── index3.js ├── index.html ├── index2.html └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | -------------------------------------------------------------------------------- /bundle.js: -------------------------------------------------------------------------------- 1 | (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 2 | 3 | 4 | 10 | 11 | 12 |

Block

13 | 14 | version: 536870912
15 | previousblockhash: '00000000000000000061abcd4f51d81ddba5498cff67fed44b287de0990b7266'
16 | merkleroot: '871148c57dad60c0cde483233b099daa3e6492a91c13b337a5413a4c4f842978'
17 | time: 1515252561
18 | bits: '180091c1'
19 |
20 |
21 |
000000000
22 |
0h/s
23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 |

Block

13 | 14 | version: 536870912
15 | previousblockhash: '00000000000000000061abcd4f51d81ddba5498cff67fed44b287de0990b7266'
16 | merkleroot: '871148c57dad60c0cde483233b099daa3e6492a91c13b337a5413a4c4f842978'
17 | time: 1515252561
18 | bits: '180091c1'
19 |
20 |
21 |
000000000
22 |
0h/s
23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const BTCMiner = require('bitcoin-miner'); 2 | // View this block in Block Explorer: https://insight.bitpay.com/block/00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9 3 | // Get it in JSON format: https://insight.bitpay.com/api/block/00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9 4 | const block = { 5 | version: 536870912, 6 | previousblockhash: '00000000000000000061abcd4f51d81ddba5498cff67fed44b287de0990b7266', 7 | merkleroot: '871148c57dad60c0cde483233b099daa3e6492a91c13b337a5413a4c4f842978', 8 | time: 1515252561, 9 | bits: '180091c1' 10 | }; 11 | 12 | const miner = new BTCMiner(block); 13 | let hash; 14 | let found = false; 15 | 16 | 17 | let nonce = 45281998 // initial nonce 18 | while (!found) { 19 | hash = miner.getHash(nonce); 20 | console.log(hash.toString('hex')); 21 | document.getElementById('hash').textContent = hash.toString('hex'); 22 | found = miner.checkHash(hash); 23 | if (found) { 24 | miner.verifyNonce(block, nonce); 25 | } 26 | nonce++; 27 | } 28 | --------------------------------------------------------------------------------