Skip to content

Commit

Permalink
merge bitcoin#24565: Remove LOCKTIME_MEDIAN_TIME_PAST constant
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Oct 25, 2024
1 parent 7068abd commit 85b0b78
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/consensus/consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ static const int COINBASE_MATURITY = 100;
/** Flags for nSequence and nLockTime locks */
/** Interpret sequence numbers as relative lock-time constraints. */
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
/** Use GetMedianTimePast() instead of nTime for end point timestamp. */
static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST = (1 << 1);

#endif // BITCOIN_CONSENSUS_CONSENSUS_H
3 changes: 1 addition & 2 deletions src/policy/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VE
static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS;

/** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */
static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE |
LOCKTIME_MEDIAN_TIME_PAST;
static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE;

CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);

Expand Down
4 changes: 2 additions & 2 deletions src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
// }

// non-final txs in mempool
SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1);
const int flags{LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST};
SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1);
const int flags{LOCKTIME_VERIFY_SEQUENCE};
// height map
std::vector<int> prevheights;

Expand Down
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3680,15 +3680,15 @@ static bool ContextualCheckBlock(const CBlock& block, BlockValidationState& stat
const int nHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;

// Enforce BIP113 (Median Time Past).
int nLockTimeFlags = 0;
bool enforce_locktime_median_time_past{false};
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV)) {
assert(pindexPrev != nullptr);
nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST;
enforce_locktime_median_time_past = true;
}

int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
? pindexPrev->GetMedianTimePast()
: block.GetBlockTime();
const int64_t nLockTimeCutoff{enforce_locktime_median_time_past ?
pindexPrev->GetMedianTimePast() :
block.GetBlockTime()};

bool fDIP0001Active_context = nHeight >= consensusParams.DIP0001Height;
bool fDIP0003Active_context = nHeight >= consensusParams.DIP0003Height;
Expand Down

0 comments on commit 85b0b78

Please sign in to comment.