@@ -236,14 +236,19 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
236236 return true ;
237237}
238238
239- // Block size and sigops have already been tested. Check that all transactions
240- // are final.
241- bool BlockAssembler::TestPackageFinalityAndSerializedSize (const CTxMemPool::setEntries& package)
239+ // Perform transaction-level checks before adding to block:
240+ // - transaction finality (locktime)
241+ // - premature witness (in case segwit transactions are added to mempool before
242+ // segwit activation)
243+ // - serialized size (in case -blockmaxsize is in use)
244+ bool BlockAssembler::TestPackageTransactions (const CTxMemPool::setEntries& package)
242245{
243246 uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
244247 BOOST_FOREACH (const CTxMemPool::txiter it, package) {
245248 if (!IsFinalTx (it->GetTx (), nHeight, nLockTimeCutoff))
246249 return false ;
250+ if (!fIncludeWitness && !it->GetTx ().wit .IsNull ())
251+ return false ;
247252 if (fNeedSizeAccounting ) {
248253 uint64_t nTxSize = ::GetSerializeSize (it->GetTx (), SER_NETWORK, PROTOCOL_VERSION);
249254 if (nPotentialBlockSize + nTxSize >= nBlockMaxSize) {
@@ -542,7 +547,7 @@ void BlockAssembler::addPackageTxs()
542547 ancestors.insert (iter);
543548
544549 // Test if all tx's are Final
545- if (!TestPackageFinalityAndSerializedSize (ancestors)) {
550+ if (!TestPackageTransactions (ancestors)) {
546551 if (fUsingModified ) {
547552 mapModifiedTx.get <ancestor_score>().erase (modit);
548553 failedTx.insert (iter);
0 commit comments