So I want to write a bitcoin script so that after a certain time period (say for example after 30 mins), the verification fails and transaction is marked invalid even if it gets broadcasted. Time locks are used so that a transaction is considered valid after a certain time period. I want the opposite to happen. So can I just enter some bogus lines of code after OP_CHECKLOCKTIMEVERIFY so that script check intentionally fails? Or is there any opcode by which I can achieve the same functionality?
-
4That isn't supported by Bitcoin because it isn't reorg-safe. A valid transaction remains valid until its inputs are spent. This ensures that the blockchain can always be reorganized.– G. MaxwellJun 22, 2020 at 4:49
-
Yes that's true. So the premise is that given an input, it can be spent by either party A or party B. The restriction is that party B must spend it within the 1st 30 mins else after that A must spend it.– Subhra MazumdarJun 22, 2020 at 5:52
-
1Again. Not something that can happen in bitcoin.– ClarisJun 22, 2020 at 16:15
1 Answer
This isn't possible with a single bitcoin sript, but your example can be realized quite easily by simply adding one more transaction to the equation:
So the premise is that given an input, it can be spent by either party A or party B. The restriction is that party B must spend it within the 1st 30 mins else after that A must spend it.
- Party A and party B cooperate to create a 1-of-2 multisig address, and then have coins sent to it
- After 30 minutes, party A will create a second transaction which pays the coins to an address that only party A controls
- Now party A can spend the coins, party B cannot
This depends on party A publishing the second transaction, but that step could also be automated and happen during the initial setup of the multisig address. The second transaction could even have a timelock added, such that it could not be published early (though party A can otherwise spend the coins at any time, so this seems unnecessary).
Otherwise, as mentioned in the comments, this sort of construction isn't possible using bitcoin script alone.
-
What if OP_RETURN is used to make the output unspendable if a locktime of say 30 mins has elapsed? Sort of burning the output in order to punish B for the delay. Then it that case neither A nor B can spend, right? Jun 26, 2020 at 4:01