| 28 | static constexpr unsigned int BLOCK_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_NULLDUMMY; |
| 29 | |
| 30 | static bool FetchAndClearCommitmentSection(const Span<const uint8_t> header, CScript& witness_commitment, std::vector<uint8_t>& result) |
| 31 | { |
| 32 | CScript replacement; |
| 33 | bool found_header = false; |
| 34 | result.clear(); |
| 35 | |
| 36 | opcodetype opcode; |
| 37 | CScript::const_iterator pc = witness_commitment.begin(); |
| 38 | std::vector<uint8_t> pushdata; |
| 39 | while (witness_commitment.GetOp(pc, opcode, pushdata)) { |
| 40 | if (pushdata.size() > 0) { |
| 41 | if (!found_header && pushdata.size() > (size_t)header.size() && Span{pushdata}.first(header.size()) == header) { |
| 42 | // pushdata only counts if it has the header _and_ some data |
| 43 | result.insert(result.end(), pushdata.begin() + header.size(), pushdata.end()); |
| 44 | pushdata.erase(pushdata.begin() + header.size(), pushdata.end()); |
| 45 | found_header = true; |
| 46 | } |
| 47 | replacement << pushdata; |
| 48 | } else { |
| 49 | replacement << opcode; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if (found_header) witness_commitment = replacement; |
| 54 | return found_header; |
| 55 | } |
| 56 | |
| 57 | static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction& cb, const CBlock& block) |
| 58 | { |