MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetWitnessCommitmentIndex

Function GetWitnessCommitmentIndex

src/validation.cpp:3384–3395  ·  view source on GitHub ↗

Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found.

Source from the content-addressed store, hash-verified

3382// Compute at which vout of the block's coinbase transaction the witness
3383// commitment occurs, or -1 if not found.
3384static int GetWitnessCommitmentIndex(const CBlock& block)
3385{
3386 int commitpos = -1;
3387 if (!block.vtx.empty()) {
3388 for (size_t o = 0; o < block.vtx[0]->vout.size(); o++) {
3389 if (block.vtx[0]->vout[o].scriptPubKey.size() >= 38 && block.vtx[0]->vout[o].scriptPubKey[0] == OP_RETURN && block.vtx[0]->vout[o].scriptPubKey[1] == 0x24 && block.vtx[0]->vout[o].scriptPubKey[2] == 0xaa && block.vtx[0]->vout[o].scriptPubKey[3] == 0x21 && block.vtx[0]->vout[o].scriptPubKey[4] == 0xa9 && block.vtx[0]->vout[o].scriptPubKey[5] == 0xed) {
3390 commitpos = o;
3391 }
3392 }
3393 }
3394 return commitpos;
3395}
3396
3397void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams)
3398{

Callers 3

ContextualCheckBlockFunction · 0.85

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected