@@ -236,14 +236,19 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
236
236
return true ;
237
237
}
238
238
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)
242
245
{
243
246
uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
244
247
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
245
248
if (!IsFinalTx (it->GetTx (), nHeight, nLockTimeCutoff))
246
249
return false ;
250
+ if (!fIncludeWitness && !it->GetTx ().wit .IsNull ())
251
+ return false ;
247
252
if (fNeedSizeAccounting ) {
248
253
uint64_t nTxSize = ::GetSerializeSize (it->GetTx (), SER_NETWORK, PROTOCOL_VERSION);
249
254
if (nPotentialBlockSize + nTxSize >= nBlockMaxSize) {
@@ -542,7 +547,7 @@ void BlockAssembler::addPackageTxs()
542
547
ancestors.insert (iter);
543
548
544
549
// Test if all tx's are Final
545
- if (!TestPackageFinalityAndSerializedSize (ancestors)) {
550
+ if (!TestPackageTransactions (ancestors)) {
546
551
if (fUsingModified ) {
547
552
mapModifiedTx.get <ancestor_score>().erase (modit);
548
553
failedTx.insert (iter);
0 commit comments