Skip to content

Commit fdfaeb6

Browse files
committed
Merge #16956: validation: Make GetWitnessCommitmentIndex public
fa607c2 validation: Make GetWitnessCommitmentIndex public (MarcoFalke) Pull request description: `GenerateCoinbaseCommitment` is public and can be used in unit tests to update the witness commitment after the list of txs in a block has been changed. However, for it to work, the existing commitment (added by default in `CreateNewBlock`) must be removed (and thus its index must be known). Make that possible by exposing the `GetWitnessCommitmentIndex` helper function in the header. ACKs for top commit: jb55: ACK fa607c2 jamesob: ACK bitcoin/bitcoin@fa607c2 promag: ACK fa607c2. fanquake: ACK fa607c2 - This unblocks work in #15845. Tree-SHA512: d563aa2c201d5fb4874e506a28f468c37e457cc8a20229c377178af08c22d3be44e19ee6e8e524b6de99236cd5f2c9e39b8009d88c26854aa774737912bd5889
2 parents 4c4ff49 + fa607c2 commit fdfaeb6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/validation.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,9 +3280,7 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa
32803280
return (height >= params.SegwitHeight);
32813281
}
32823282

3283-
// Compute at which vout of the block's coinbase transaction the witness
3284-
// commitment occurs, or -1 if not found.
3285-
static int GetWitnessCommitmentIndex(const CBlock& block)
3283+
int GetWitnessCommitmentIndex(const CBlock& block)
32863284
{
32873285
int commitpos = -1;
32883286
if (!block.vtx.empty()) {

src/validation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa
384384
/** When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index */
385385
bool RewindBlockIndex(const CChainParams& params) LOCKS_EXCLUDED(cs_main);
386386

387+
/** Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found */
388+
int GetWitnessCommitmentIndex(const CBlock& block);
389+
387390
/** Update uncommitted block structures (currently: only the witness reserved value). This is safe for submitted blocks. */
388391
void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams);
389392

0 commit comments

Comments
 (0)