Skip to content

Commit 53b0e16

Browse files
committed
Don't compute optional witness commitment (optimization).
1 parent b2d690e commit 53b0e16

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/chain/block.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ bool block::is_invalid_witness_commitment() const NOEXCEPT
600600
if (coinbase->inputs_ptr()->empty())
601601
return false;
602602

603+
// If no block tx has witness data the commitment is optional (bip141).
604+
if (!is_segregated())
605+
return false;
606+
603607
// If there is a valid commitment, return false (valid).
604608
// Coinbase input witness must be 32 byte witness reserved value (bip141).
605609
// Last output of commitment pattern holds the committed value (bip141).
@@ -610,10 +614,8 @@ bool block::is_invalid_witness_commitment() const NOEXCEPT
610614
if (committed == sha256::double_hash(
611615
generate_merkle_root(true), reserved))
612616
return false;
613-
614-
// If no valid commitment, return true (invalid) if segregated.
615-
// If no block tx has witness data the commitment is optional (bip141).
616-
return is_segregated();
617+
618+
return true;
617619
}
618620

619621
//*****************************************************************************

0 commit comments

Comments
 (0)