diff --git a/src/auxpow.cpp b/src/auxpow.cpp index 4994b9a02..e4ab63341 100644 --- a/src/auxpow.cpp +++ b/src/auxpow.cpp @@ -104,13 +104,13 @@ bool CAuxPow::Check(uint256 hashAuxBlock, int nChainID) return true; } -CScript MakeCoinbaseWithAux(unsigned int nBits, unsigned int nExtraNonce, vector& vchAux) +CScript MakeCoinbaseWithAux(unsigned int nHeight, unsigned int nExtraNonce, vector& vchAux) { vector vchAuxWithHeader(UBEGIN(pchMergedMiningHeader), UEND(pchMergedMiningHeader)); vchAuxWithHeader.insert(vchAuxWithHeader.end(), vchAux.begin(), vchAux.end()); // Push OP_2 just in case we want versioning later - return CScript() << nBits << nExtraNonce << OP_2 << vchAuxWithHeader; + return CScript() << nHeight << CScriptNum(nExtraNonce) << COINBASE_FLAGS << OP_2 << vchAuxWithHeader; } @@ -125,7 +125,8 @@ void IncrementExtraNonceWithAux(CBlock* pblock, CBlockIndex* pindexPrev, unsigne } ++nExtraNonce; - pblock->vtx[0].vin[0].scriptSig = MakeCoinbaseWithAux(pblock->nBits, nExtraNonce, vchAux); + unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2 + pblock->vtx[0].vin[0].scriptSig = MakeCoinbaseWithAux(nHeight, nExtraNonce, vchAux); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); } diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 4103e7f4c..55b51a556 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -763,7 +763,8 @@ Value getworkaux(const Array& params, bool fHelp) RemoveMergedMiningHeader(vchAux); - pblock->vtx[0].vin[0].scriptSig = MakeCoinbaseWithAux(pblock->nBits, nExtraNonce, vchAux); + unsigned int nHeight = chainActive.Tip()->nHeight+1; // Height first in coinbase required for block.version=2 + pblock->vtx[0].vin[0].scriptSig = MakeCoinbaseWithAux(nHeight, nExtraNonce, vchAux); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); if (params.size() > 2) @@ -859,9 +860,10 @@ Value getauxblock(const Array& params, bool fHelp) pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); pblock->nNonce = 0; - // Push OP_2 just in case we want versioning later - pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CScriptNum(1) << OP_2; - pblock->hashMerkleRoot = pblock->BuildMerkleTree(); + + // Update nExtraNonce + static unsigned int nExtraNonce = 0; + IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); // Sets the version pblock->SetAuxPow(new CAuxPow());