## How to correctly set attributes for block hash and nBits in PIVX Fork?

0

2

I've cloned PIVX(basically a DASH fork) and modified basic parameters. It compiles fine. When I'm trying to run it the server starts and the debug log file shows following errors:

ERROR: CheckProofOfWork() : hash doesn't match nBits
ERROR: CheckBlockHeader() : proof of work failed

To generate my genesis block I've changed the following parameters:

• pszTimestamp : Used a random latest news.
• scriptPubKey : Used the genesis hex from generation commands mentioned in this pastebin link.

• genesis.nTime : Got the latest unix timestamp.

• genesis.nNonce : Obtained it from genesis block creation algorithm mentioned in this pastebin link.

I was able to successfully generate new genesis hash as well as merkle root. But after compiling it and I get the above error.

I've tried looking for the solution on the web but most of them had no concrete answers or no answers at all except this one.

It explains that the hash of my genesis block is greater than the target hash which is obtained using nBits variable. So my question is how do I make sure that my genesis hash is less than the target hash to get rid of the errors mentioned?

The issue with generating a hash for the genesis was I used scrypt algorithm to generate the hash. You may come across paste bin links with this method scrypt_1024_1_1_256_sp_sse2.
So in my case, I replaced this with the method offered by uint256 class. You can find this genesis creation logic at this pastebin.