aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-11-06 01:42:38 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2016-06-22 15:42:59 +0200
commit8b49040854be2e26b66366aeae1cba4716f93d93 (patch)
treeb217f3fb71bc0745c1f74ab239fbe0ebcf52a751 /src/miner.cpp
parent449f9b8debcceb61a92043bc7031528a53627c47 (diff)
BIP141: Commitment structure and deployment
Includes a fix by Suhas Daftuar and LongShao007
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)) {