diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index d04b66e2..897d1ee4 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -593,9 +593,7 @@ Chain.prototype._verify = function _verify(block, prev, callback) { } // Get timestamp for tx.isFinal(). - ts = (state.lockFlags & constants.flags.MEDIAN_TIME_PAST) !== 0 - ? medianTime - : block.ts; + ts = state.hasMTP() ? medianTime : block.ts; // Check all transactions for (i = 0; i < block.txs.length; i++) { @@ -2546,6 +2544,15 @@ DeploymentState.prototype.hasCLTV = function hasCLTV() { return (this.flags & constants.flags.VERIFY_CHECKLOCKTIMEVERIFY) !== 0; }; +/** + * Test whether median time past locktime is active. + * @returns {Boolean} + */ + +DeploymentState.prototype.hasMTP = function hasMTP() { + return (this.lockFlags & constants.flags.MEDIAN_TIME_PAST) !== 0 +}; + /** * Test whether csv is active. * @returns {Boolean}