<p>That description is incorrect. There is no way to access the current time or height from within the Script language.</p>
<p>Instead, there is a level of indirection:</p>
<ul>
<li>A transactions nLockTime or nSequence enforces an absolute or relative locktime on the transaction.</li>
<li>The <code>OP_CHECKLOCKTIMEVERIFY</code> and <code>OP_SEQUENCEVERIFY</code> opcodes inside script compare the top stack element with the transaction's nLockTime or nSequence value.</li>
</ul>
<p>Functionally, together these constructions do let you effectively write scripts that can enforce time constraints. E.g. a script using <code>OP_CHECKLOCKTIMEVERIFY</code> can require the nLockTime of the spending transaction to be at least N, and thereby indirectly force the transaction to not be minable until N has passed.</p>
<p>The advantage of this split is that transaction script validity is a single boolean value that only needs to be verified once: a transaction's script validity is either always valid or always invalid.</p>

CC BY-SA 4.0
2023-12-25T23:40:13.633Z
2023-12-25T23:40:13.633Z
Pieter Wuille
<p>In the &quot;Freezing funds until a time in the future&quot; example here <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Script</a> it mentions that the &quot;Top stack item is checked against the current time or block height&quot;</p>
<p>Does this mean that the stack has access to variables such as the current block height and time? Or is this incorrect on the wiki. I understand when CTLV is used in conjunction with nlocktime and they are checked against each other. But when nlocktime is used alone, is their a stack operation which pulls the current block time from the system?</p>
<p>If so, what other system level variables does the stack have access to?</p>

<transaction-verification><locktime>
Does the stack have access to the current block height when validating transaction?
Steve
# Does the stack have access to the current block height when validating transaction?

(Asked by: username_0 on 2023-12-25)

In the "Freezing funds until a time in the future" example here <https://en.bitcoin.it/wiki/Script> it mentions that the "Top stack item is checked against the current time or block height"

Does this mean that the stack has access to variables such as the current block height and time? Or is this incorrect on the wiki. I understand when CTLV is used in conjunction with nlocktime and they are checked against each other. But when nlocktime is used alone, is their a stack operation which pulls the current block time from the system?

If so, what other system level variables does the stack have access to?

**Tags:** transaction-verification, locktime


---

## 1 answers

### Answer by username_1 on 2023-12-25. Score: 3

That description is incorrect. There is no way to access the current time or height from within the Script language.

Instead, there is a level of indirection:

* A transactions nLockTime or nSequence enforces an absolute or relative locktime on the transaction.
* The `OP_CHECKLOCKTIMEVERIFY` and `OP_SEQUENCEVERIFY` opcodes inside script compare the top stack element with the transaction's nLockTime or nSequence value.

Functionally, together these constructions do let you effectively write scripts that can enforce time constraints. E.g. a script using `OP_CHECKLOCKTIMEVERIFY` can require the nLockTime of the spending transaction to be at least N, and thereby indirectly force the transaction to not be minable until N has passed.

The advantage of this split is that transaction script validity is a single boolean value that only needs to be verified once: a transaction's script validity is either always valid or always invalid.


---

