@@ -691,36 +691,38 @@ bool transaction::is_overspent() const NOEXCEPT
691691 return spend () > value ();
692692}
693693
694- constexpr bool is_non_coinbase_mature (size_t tx_height, size_t height) NOEXCEPT
694+ constexpr bool is_non_coinbase_immature (size_t prevout_height,
695+ size_t height) NOEXCEPT
695696{
696- return tx_height <= height ;
697+ return height < prevout_height ;
697698}
698699
699700// static
700701// *****************************************************************************
701702// CONSENSUS: Coinbase output matures at 100 blocks depth.
702703// CONSENSUS: Genesis coinbase is forever immature (exception).
703704// *****************************************************************************
704- bool transaction::is_coinbase_mature (size_t coinbase_height,
705+ bool transaction::is_coinbase_immature (size_t coinbase_height,
705706 size_t height) NOEXCEPT
706707{
707- return ! is_zero (coinbase_height) &&
708- ceilinged_add (coinbase_height, coinbase_maturity) <= height ;
708+ return is_zero (coinbase_height) || (height < ceilinged_add (coinbase_height,
709+ coinbase_maturity)) ;
709710}
710711
711712bool transaction::is_immature (size_t height) const NOEXCEPT
712713{
713714 BC_ASSERT (!is_coinbase ());
714715
715716 // Spends internal to a block are handled by block validation.
716- const auto mature = [=](const auto & input) NOEXCEPT
717+ const auto immature = [=](const auto & input) NOEXCEPT
717718 {
719+ const auto prevout_height = input->metadata .prevout_height ;
718720 return input->metadata .coinbase ?
719- is_coinbase_mature (input-> metadata . prevout_height , height) :
720- is_non_coinbase_mature (input-> metadata . prevout_height , height);
721+ is_coinbase_immature ( prevout_height, height) :
722+ is_non_coinbase_immature ( prevout_height, height);
721723 };
722724
723- return ! std::all_of (inputs_->begin (), inputs_->end (), mature );
725+ return std::any_of (inputs_->begin (), inputs_->end (), immature );
724726}
725727
726728// static
0 commit comments