Last active
March 1, 2019 11:09
-
-
Save nssy/e78059a5d54187734a9f907f6734d679 to your computer and use it in GitHub Desktop.
Check difficulty from pow hash (Monero v8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
node depanancies: | |
npm install bignum | |
*/ | |
var bignum = require('bignum'); | |
var diff1 = bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); | |
// This is what miner submits | |
var powHash; | |
// Grab this from https://xmrchain.net | |
powHash = 'a70043cad329b7d1af2d6d1b93a3d8e86159d6ab17f73875a8f9d80000000000'; | |
// var hash = new Buffer(powHash, 'hex'); | |
var hash = Buffer.from(powHash, 'hex'); | |
var hashArray = hash.toJSON().data.reverse(); | |
var hashNum = bignum.fromBuffer(Buffer.from(hashArray)); | |
var hashDiff = diff1.div(hashNum); | |
console.log(hashDiff.toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment