timeLockTemplateScript

Builds the time lock template (redeem) script.

This is a time-locked single-sig template: coins sent to a time lock vault address cannot be moved until a committed unlock value — a block height or, at/above the BIP-65 500,000,000 split, a Unix timestamp — is reached, and only the holder of the corresponding private key can spend them.

Altstack layout when this script begins executing (top → bottom):

  1. derivation index (visible arg, from the locking script — for HD wallet rediscovery)

  2. unlock value (visible arg, from the locking script — used as the locktime)

  3. pubkey (from the constraint script)

The signature is provided separately by the satisfier on the main stack.

Execution: FROMALTSTACK DROP — pop the derivation index and discard it. It is committed in the locking script so the wallet can re-derive the owning key during vault discovery, but the spend logic does not use it. FROMALTSTACK CLTV DROP — pop the unlock value; CHECKLOCKTIMEVERIFY fails the script unless the spending tx's nLockTime is at or past it, on the matching side of the BIP-65 height/time split. DROP cleans the value off the stack (CLTV does not consume its argument). FROMALTSTACK CHECKSIGVERIFY — pop the pubkey and verify the satisfier's signature against it; abort on failure.

Spend conditions, combined: the chain has reached the committed unlock value (block height, or median-time-past for a timestamp) AND the spender produced a valid signature for the committed pubkey.

Only the hash160 of this script is committed on-chain (in the locking script of every time locked UTXO); the template script bytes themselves are never published. The same template is shared across every time lock vault, so the spender reveals these bytes in the satisfier at spend time and the network verifies they hash to the committed value before executing.