transactions – Can a spend before a timestamp condition be put on a Bitcoin UTXO?


You can do this by creating a P2WSH output with the following script:

OP_IF
  <condition 1>
OP_ELSE
  <timestamp>
  OP_CHECKLOCKTIMEVERIFY
  OP_DROP
  <condition 2>
OP_ENDIF

Then depending on what condition you’re taking you put 1 or 0 on top of the initial stack when spending.

You can also do this more privately (and in most cases cheaply) by using P2TR and splitting the two conditions into separate tree leaves. If the first condition consists of a single public key (or a set of keys that can be aggregated) you can use it as the internal key, and when you’re taking that condition using the key path you don’t even need to reveal a script.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top