aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBtcDrak <btcdrak@gmail.com>2016-02-16 16:33:31 +0000
committerBtcDrak <btcdrak@gmail.com>2016-03-18 09:28:40 +0000
commit648be9b442587cc1682052bca80625aea906a01d (patch)
tree714dcff23c0ba41551d3de957eb35a8f00093c2c /src
parentee40924fef1e8835b9ef865360b126952ad8359d (diff)
downloadbitcoin-648be9b442587cc1682052bca80625aea906a01d.tar.xz
Soft fork logic for BIP113
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 39d68af372..3035a3e5dd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3310,12 +3310,18 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1;
const Consensus::Params& consensusParams = Params().GetConsensus();
+ // Start enforcing BIP113 (Median Time Past) using versionbits logic.
+ int nLockTimeFlags = 0;
+ if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, versionbitscache) == THRESHOLD_ACTIVE) {
+ nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST;
+ }
+
+ int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
+ ? pindexPrev->GetMedianTimePast()
+ : block.GetBlockTime();
+
// Check that all transactions are finalized
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
- int nLockTimeFlags = 0;
- int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
- ? pindexPrev->GetMedianTimePast()
- : block.GetBlockTime();
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) {
return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal");
}