Skip to content

Instantly share code, notes, and snippets.

@nssy
Last active March 1, 2019 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nssy/e78059a5d54187734a9f907f6734d679 to your computer and use it in GitHub Desktop.
Save nssy/e78059a5d54187734a9f907f6734d679 to your computer and use it in GitHub Desktop.
Check difficulty from pow hash (Monero v8)
/*
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