diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7af71828d..2c1af165f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1303,7 +1303,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) else { CBlockHeader bh = pastBlockIndex->GetBlockHeader(); - uint256 pastHash = bh.GetVerusEntropyHash(height); + uint256 pastHash = bh.GetVerusEntropyHash(height - 100); // if height is over when Nonce is required to be the new format, we check that the new format is correct // if over when we have the new POS hash function, we validate that as well diff --git a/src/miner.cpp b/src/miner.cpp index 86235aa4b..53b69069e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -804,6 +804,18 @@ int32_t waitForPeers(const CChainParams &chainparams) } #ifdef ENABLE_WALLET +CBlockIndex *get_chainactive(int32_t height) +{ + if ( chainActive.Tip() != 0 ) + { + if ( height <= chainActive.Tip()->nHeight ) + return(chainActive[height]); + // else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight); + } + //fprintf(stderr,"get_chainactive null chainActive.Tip() height %d\n",height); + return(0); +} + /* * A separate thread to stake, while the miner threads mine. */ @@ -959,7 +971,9 @@ void static VerusStaker(CWallet *pwallet) printf("staking reward %.8f %s!\n", (double)subsidy / (double)COIN, ASSETCHAINS_SYMBOL); arith_uint256 post; post.SetCompact(pblock->GetVerusPOSTarget()); - printf(" hash: %s \ntarget: %s\n", pblock->vtx[pblock->vtx.size()-1].GetVerusPOSHash(&(pblock->nNonce), 0, Mining_height, pindexPrev->GetBlockHeader().GetVerusEntropyHash(Mining_height)).GetHex().c_str(), ArithToUint256(post).GetHex().c_str()); + pindexPrev = get_chainactive(Mining_height - 100); + printf(" hash: %s \ntarget: %s\n", + CTransaction::_GetVerusPOSHash(&(pblock->nNonce), pblock->vtx[pblock->vtx.size()-1].vin[0].prevout.hash, 0, Mining_height, pindexPrev->GetBlockHeader().GetVerusEntropyHash(Mining_height - 100), pblock->vtx[pblock->vtx.size()-1].vout[0].nValue).GetHex().c_str(), ArithToUint256(post).GetHex().c_str()); if (unlockTime > Mining_height && subsidy >= ASSETCHAINS_TIMELOCKGTE) printf("- timelocked until block %i\n", unlockTime); else diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 39d338959..a638131a0 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -65,7 +65,7 @@ bool CBlockHeader::GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const // ) // hashWriter << height; // return hashWriter.GetHash(); - CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION); + CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION); hashWriter << ASSETCHAINS_MAGIC; hashWriter << nNonce; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8c6b1eb50..e12a352a6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1016,7 +1016,7 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult, if (pastBlockIndex = komodo_chainactive(nHeight - 100)) { CBlockHeader bh = pastBlockIndex->GetBlockHeader(); - uint256 pastHash = bh.GetVerusEntropyHash(nHeight); + uint256 pastHash = bh.GetVerusEntropyHash(nHeight - 100); CPOSNonce curNonce; BOOST_FOREACH(COutput &txout, vecOutputs)