CreateNewBlock: Stick height in coinbase so we pass template sanity check
This commit is contained in:
parent
60755dbf76
commit
b867e409e5
1 changed files with 6 additions and 5 deletions
|
@ -124,6 +124,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
const int nHeight = pindexPrev->nHeight + 1;
|
||||
CCoinsViewCache view(pcoinsTip);
|
||||
|
||||
// Priority order to process transactions
|
||||
|
@ -138,7 +139,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||
mi != mempool.mapTx.end(); ++mi)
|
||||
{
|
||||
const CTransaction& tx = mi->second.GetTx();
|
||||
if (tx.IsCoinBase() || !IsFinalTx(tx, pindexPrev->nHeight + 1))
|
||||
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight))
|
||||
continue;
|
||||
|
||||
COrphan* porphan = NULL;
|
||||
|
@ -181,7 +182,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||
CAmount nValueIn = coins->vout[txin.prevout.n].nValue;
|
||||
nTotalIn += nValueIn;
|
||||
|
||||
int nConf = pindexPrev->nHeight - coins->nHeight + 1;
|
||||
int nConf = nHeight - coins->nHeight;
|
||||
|
||||
dPriority += (double)nValueIn * nConf;
|
||||
}
|
||||
|
@ -269,7 +270,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||
continue;
|
||||
|
||||
CTxUndo txundo;
|
||||
UpdateCoins(tx, state, view, txundo, pindexPrev->nHeight+1);
|
||||
UpdateCoins(tx, state, view, txundo, nHeight);
|
||||
|
||||
// Added
|
||||
pblock->vtx.push_back(tx);
|
||||
|
@ -309,8 +310,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||
LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize);
|
||||
|
||||
// Compute final coinbase transaction.
|
||||
txNew.vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
|
||||
txNew.vin[0].scriptSig = CScript() << OP_0 << OP_0;
|
||||
txNew.vout[0].nValue = GetBlockValue(nHeight, nFees);
|
||||
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
||||
pblock->vtx[0] = txNew;
|
||||
pblocktemplate->vTxFees[0] = -nFees;
|
||||
|
||||
|
|
Loading…
Reference in a new issue