aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 989ad11a26..a7bf9ae84c 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -93,6 +93,7 @@ void BlockAssembler::resetBlock()
// Reserve space for coinbase tx
nBlockSize = 1000;
nBlockSigOps = 100;
+ fIncludeWitness = false;
// These counters do not include coinbase tx
nBlockTx = 0;
@@ -134,6 +135,14 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
? nMedianTimePast
: pblock->GetBlockTime();
+ // Decide whether to include witness transactions
+ // This is only needed in case the witness softfork activation is reverted
+ // (which would require a very deep reorganization) or when
+ // -promiscuousmempoolflags is used.
+ // TODO: replace this with a call to main to assess validity of a mempool
+ // transaction (which in most cases can be a no-op).
+ fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus());
+
addPriorityTxs();
addPackageTxs();
@@ -150,6 +159,7 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
pblock->vtx[0] = coinbaseTx;
+ pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
pblocktemplate->vTxFees[0] = -nFees;
// Fill in header
@@ -299,6 +309,10 @@ void BlockAssembler::addScoreTxs()
continue;
}
+ // cannot accept witness transactions into a non-witness block
+ if (!fIncludeWitness && !iter->GetTx().wit.IsNull())
+ continue;
+
// If tx is dependent on other mempool txs which haven't yet been included
// then put it in the waitSet
if (isStillDependent(iter)) {
@@ -543,6 +557,10 @@ void BlockAssembler::addPriorityTxs()
continue;
}
+ // cannot accept witness transactions into a non-witness block
+ if (!fIncludeWitness && !iter->GetTx().wit.IsNull())
+ continue;
+
// If tx is dependent on other mempool txs which haven't yet been included
// then put it in the waitSet
if (isStillDependent(iter)) {