I am the sole developer of a cryptocurrency. However, my current issue is beyond my small 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 prevHash 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 SEGFAULT.
Relevant portion of code:
// Check coinbase reward
int64_t nFees = 0;
uint256 prevHash = 0;
prevHash = pindexBest->pprev->GetBlockHash();
if (vtx.GetValueOut() > (IsProofOfWork()? (GetProofOfWorkReward(nFees, prevHash) - vtx.GetMinFee() + MIN_TX_FEE) : 0)) return state.DoS(50, error("CheckBlock() : coinbase reward exceeded %s %s", FormatMoney(vtx.GetValueOut()).c_str(), 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:1935
Based Blockchain Network