MCPcopy Create free account
hub / github.com/ElementsProject/elements / FetchAndClearCommitmentSection

Function FetchAndClearCommitmentSection

src/signet.cpp:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28static constexpr unsigned int BLOCK_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_NULLDUMMY;
29
30static 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
57static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction& cb, const CBlock& block)
58{

Callers 1

CreateMethod · 0.85

Calls 7

GetOpMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected