Make GetWitnessCommitmentIndex callable on blocks without a coinbase txn.
This isn't actually needed anywhere, but it's less brittle.
This commit is contained in:
parent
ebfd653798
commit
ada0caa165
1 changed files with 5 additions and 3 deletions
|
@ -2901,9 +2901,11 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa
|
||||||
static int GetWitnessCommitmentIndex(const CBlock& block)
|
static int GetWitnessCommitmentIndex(const CBlock& block)
|
||||||
{
|
{
|
||||||
int commitpos = -1;
|
int commitpos = -1;
|
||||||
for (size_t o = 0; o < block.vtx[0]->vout.size(); o++) {
|
if (!block.vtx.empty()) {
|
||||||
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) {
|
for (size_t o = 0; o < block.vtx[0]->vout.size(); o++) {
|
||||||
commitpos = o;
|
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) {
|
||||||
|
commitpos = o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return commitpos;
|
return commitpos;
|
||||||
|
|
Loading…
Reference in a new issue