diff options
author | Dhruv Mehta <856960+dhruv@users.noreply.github.com> | 2021-06-20 11:26:35 -0700 |
---|---|---|
committer | Dhruv Mehta <856960+dhruv@users.noreply.github.com> | 2021-07-07 22:13:01 -0700 |
commit | a806647d260132a00cd633160040625c7dd17803 (patch) | |
tree | 87d9e1a91dabe4180f1504e933c9d6898338bc13 /src/validation.cpp | |
parent | 189128c220190a588500b8e74ee7ae47671b9558 (diff) | |
download | bitcoin-a806647d260132a00cd633160040625c7dd17803.tar.xz |
[validation] Always include merkle root in coinbase commitment
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 863483bcfb..8cb4f64dd7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3094,25 +3094,23 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc std::vector<unsigned char> commitment; int commitpos = GetWitnessCommitmentIndex(block); std::vector<unsigned char> ret(32, 0x00); - if (DeploymentEnabled(consensusParams, Consensus::DEPLOYMENT_SEGWIT)) { - if (commitpos == NO_WITNESS_COMMITMENT) { - uint256 witnessroot = BlockWitnessMerkleRoot(block, nullptr); - CHash256().Write(witnessroot).Write(ret).Finalize(witnessroot); - CTxOut out; - out.nValue = 0; - out.scriptPubKey.resize(MINIMUM_WITNESS_COMMITMENT); - out.scriptPubKey[0] = OP_RETURN; - out.scriptPubKey[1] = 0x24; - out.scriptPubKey[2] = 0xaa; - out.scriptPubKey[3] = 0x21; - out.scriptPubKey[4] = 0xa9; - out.scriptPubKey[5] = 0xed; - memcpy(&out.scriptPubKey[6], witnessroot.begin(), 32); - commitment = std::vector<unsigned char>(out.scriptPubKey.begin(), out.scriptPubKey.end()); - CMutableTransaction tx(*block.vtx[0]); - tx.vout.push_back(out); - block.vtx[0] = MakeTransactionRef(std::move(tx)); - } + if (commitpos == NO_WITNESS_COMMITMENT) { + uint256 witnessroot = BlockWitnessMerkleRoot(block, nullptr); + CHash256().Write(witnessroot).Write(ret).Finalize(witnessroot); + CTxOut out; + out.nValue = 0; + out.scriptPubKey.resize(MINIMUM_WITNESS_COMMITMENT); + out.scriptPubKey[0] = OP_RETURN; + out.scriptPubKey[1] = 0x24; + out.scriptPubKey[2] = 0xaa; + out.scriptPubKey[3] = 0x21; + out.scriptPubKey[4] = 0xa9; + out.scriptPubKey[5] = 0xed; + memcpy(&out.scriptPubKey[6], witnessroot.begin(), 32); + commitment = std::vector<unsigned char>(out.scriptPubKey.begin(), out.scriptPubKey.end()); + CMutableTransaction tx(*block.vtx[0]); + tx.vout.push_back(out); + block.vtx[0] = MakeTransactionRef(std::move(tx)); } UpdateUncommittedBlockStructures(block, pindexPrev, consensusParams); return commitment; |