Skip to content

Commit d6f1732

Browse files
committed
Change is_coinbase_mature to _immature, style.
1 parent 50f7d26 commit d6f1732

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

include/bitcoin/system/chain/transaction.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class BC_API transaction
5050
static bool is_relative_locktime_applied(bool coinbase, uint32_t version,
5151
uint32_t sequence) NOEXCEPT;
5252

53-
/// Not genesis and at least 100 blocks deep.
54-
static bool is_coinbase_mature(size_t coinbase_height,
53+
/// Genesis or less than 100 blocks deep.
54+
static bool is_coinbase_immature(size_t coinbase_height,
5555
size_t height) NOEXCEPT;
5656

5757
/// Optimized non-witness hash derivation using witness-serialized tx.

src/chain/transaction.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

711712
bool 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

Comments
 (0)