| 4005 | } |
| 4006 | |
| 4007 | void ChainstateManager::GenerateCoinbaseCommitment(CBlock& block, const CBlockIndex* pindexPrev) const |
| 4008 | { |
| 4009 | int commitpos = GetWitnessCommitmentIndex(block); |
| 4010 | std::vector<unsigned char> ret(32, 0x00); |
| 4011 | if (commitpos == NO_WITNESS_COMMITMENT) { |
| 4012 | uint256 witnessroot = BlockWitnessMerkleRoot(block); |
| 4013 | CHash256().Write(witnessroot).Write(ret).Finalize(witnessroot); |
| 4014 | CTxOut out; |
| 4015 | out.nValue = 0; |
| 4016 | out.scriptPubKey.resize(MINIMUM_WITNESS_COMMITMENT); |
| 4017 | out.scriptPubKey[0] = OP_RETURN; |
| 4018 | out.scriptPubKey[1] = 0x24; |
| 4019 | out.scriptPubKey[2] = 0xaa; |
| 4020 | out.scriptPubKey[3] = 0x21; |
| 4021 | out.scriptPubKey[4] = 0xa9; |
| 4022 | out.scriptPubKey[5] = 0xed; |
| 4023 | memcpy(&out.scriptPubKey[6], witnessroot.begin(), 32); |
| 4024 | CMutableTransaction tx(*block.vtx[0]); |
| 4025 | tx.vout.push_back(out); |
| 4026 | block.vtx[0] = MakeTransactionRef(std::move(tx)); |
| 4027 | } |
| 4028 | UpdateUncommittedBlockStructures(block, pindexPrev); |
| 4029 | } |
| 4030 | |
| 4031 | bool HasValidProofOfWork(std::span<const CBlockHeader> headers, const Consensus::Params& consensusParams) |
| 4032 | { |