diff --git a/src/chainparams.cpp b/src/chainparams.cpp index f542d4df2..0dfa2a0d5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -39,19 +39,20 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi // vMerkleTree: 12630d16a9 CMutableTransaction txNew; + txNew.nVersion = 1; txNew.nTime = nTime; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].scriptSig = CScript() << 0 << CScriptNum(42) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); - txNew.vout[0].SetEmpty(); + txNew.vout[0].nValue = genesisReward; CBlock genesis; - genesis.vtx.push_back(txNew); - genesis.hashPrevBlock.SetNull(); - genesis.nVersion = nVersion; genesis.nTime = nTime; genesis.nBits = nBits; genesis.nNonce = nNonce; + genesis.nVersion = nVersion; + genesis.vtx.push_back(txNew); + genesis.hashPrevBlock.SetNull(); genesis.hashMerkleRoot = BlockMerkleRoot(genesis); return genesis; } @@ -130,20 +131,7 @@ public: nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; - const char* pszTimestamp = "20 Feb 2014 Bitcoin ATMs come to USA"; - CMutableTransaction txNew; - txNew.nTime = 1393221600; - txNew.vin.resize(1); - txNew.vout.resize(1); - txNew.vin[0].scriptSig = CScript() << 0 << CScriptNum(42) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); - txNew.vout[0].SetEmpty(); - genesis.vtx.push_back(txNew); - genesis.hashPrevBlock.SetNull(); - genesis.nVersion = 1; - genesis.nTime = 1393221600; - genesis.nBits = 0x1e0fffff; - genesis.nNonce = 164482; - genesis.hashMerkleRoot = BlockMerkleRoot(genesis); + genesis = CreateGenesisBlock(1393221600, 164482, 0x1e0fffff, 1, 0); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x000001faef25dec4fbcf906e6242621df2c183bf232f263d0ba5b101911e4563")); assert(genesis.hashMerkleRoot == uint256S("0x12630d16a97f24b287c8c2594dda5fb98c9e6c70fc61d44191931ea2aa08dc90")); diff --git a/src/main.cpp b/src/main.cpp index 9e2b964da..1f323b246 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2413,14 +2413,14 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; } - // Reject proof-of-work after nLastPOWBlock + // Reject proof of work at height nLastPOWBlock if (block.IsProofOfWork() && pindex->nHeight > chainparams.GetConsensus().nLastPOWBlock) - return state.DoS(100, error("%s: reject proof-of-work at height %d", __func__, pindex->nHeight), + return state.DoS(100, error("ConnectBlock(): reject proof-of-work at height %d", pindex->nHeight), REJECT_INVALID, "bad-pow-height"); // Check difficulty if (block.nBits != GetNextTargetRequired(pindex->pprev, &block, block.IsProofOfStake(), chainparams.GetConsensus())) - return state.DoS(100, error("%s: incorrect difficulty", __func__), + return state.DoS(100, error("ConnectBlock(): incorrect difficulty"), REJECT_INVALID, "bad-diffbits"); pindex->nStakeModifier = ComputeStakeModifier(pindex->pprev, block.IsProofOfStake() ? block.vtx[1].vin[0].prevout.hash : pindex->GetBlockHash()); @@ -2430,17 +2430,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin const COutPoint &prevout = block.vtx[1].vin[0].prevout; const CCoins *coins = view.AccessCoins(prevout.hash); if (!coins) - return state.DoS(100, error("%s: kernel input unavailable", __func__), + return state.DoS(100, error("ConnectBlock(): kernel input unavailable"), REJECT_INVALID, "bad-cs-kernel"); // Check proof-of-stake min confirmations if (pindex->nHeight - coins->nHeight < chainparams.GetConsensus().nStakeMinConfirmations) return state.DoS(100, - error("%s: tried to stake at depth %d", __func__, pindex->nHeight - coins->nHeight), + error("ConnectBlock(): tried to stake at depth %d", pindex->nHeight - coins->nHeight), REJECT_INVALID, "bad-cs-premature"); if (!CheckStakeKernelHash(pindex->pprev, block.nBits, coins, prevout, block.vtx[1].nTime)) - return state.DoS(100, error("%s: proof-of-stake hash doesn't match nBits", __func__), + return state.DoS(100, error("ConnectBlock(): proof-of-stake hash doesn't match nBits"), REJECT_INVALID, "bad-cs-proofhash"); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f5e8d108e..3e6d8f959 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -820,7 +820,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int // Calculate reward { - int64_t nReward = GetProofOfStakeSubsidy() + nFees; + int64_t nReward = nFees + GetProofOfStakeSubsidy(); if (nReward < 0) return false;