diff options
| author | Ross Nicoll <[email protected]> | 2014-08-17 11:22:02 +0100 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2014-08-17 11:24:31 +0100 |
| commit | 223ed2eaddcbbdc69f1f11a8fcdf27b4ab6526e0 (patch) | |
| tree | 3bd199051622965c8b21955eb122493616945ccb /src/auxpow.cpp | |
| parent | Added further diagnostic detail in case of transaction ID clash. (diff) | |
| download | discoin-223ed2eaddcbbdc69f1f11a8fcdf27b4ab6526e0.tar.xz discoin-223ed2eaddcbbdc69f1f11a8fcdf27b4ab6526e0.zip | |
Correct format of AuxPow coinbase script.
AuxPoW coinbase scripts now include block height as per BIP0034, which also
resolves issue of transactions being generated which collide.
Diffstat (limited to 'src/auxpow.cpp')
| -rw-r--r-- | src/auxpow.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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<unsigned char>& vchAux) +CScript MakeCoinbaseWithAux(unsigned int nHeight, unsigned int nExtraNonce, vector<unsigned char>& vchAux) { vector<unsigned char> 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(); } |