I am the sole developer of a cryptocurrency. However, my current issue is beyond my but growing c++ knowledge base.

I am looking to clone over a copy of Peercoin, and modify it to properly suit my current blockchain. I have achieved a large portion of this already, including the algo switch, diff adjustment change, and many small options changes to link to my current blockchain.

My issue, my original code is 6.x and does not include a “checkBlock()” function. This function calls getProofOfWorkReward, which I have changed to use nfees and instead of nBits in order to fully match my current code.

The problem is, when loading the genesis block, a coinbase transaction that is checked by checkBlock, there is no prevHash. As such it returns as NULL throwing checkblock out of wack and causing a .

Relevant portion of code:

// coinbase reward
int64_t nFees = 0;
uint256 prevHash = 0;
if (pindexBest->pprev)
prevHash = pindexBest->pprev->GetBlockHash();

if (vtx[0].GetValueOut() > (IsProofOfWork()? (GetProofOfWorkReward(nFees, prevHash) - vtx[0].GetMinFee() + MIN_TX_FEE) : 0))
    return state.DoS(50, error("CheckBlock() : coinbase reward exceeded %s  %s", 
               FormatMoney(IsProofOfWork()? GetProofOfWorkReward(nFees, prevHash) : 0).c_str()));  

My GDB output:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000442ce6 in CBlockIndex::GetBlockHash (this=0x0) at main.h:19

Source link
Based Blockchain Network


Please enter your comment!
Please enter your name here