Author: Luke Dashjr 2016-08-17 04:40:34
Published on: 2016-08-17T04:40:34+00:00
On August 17, 2016, Johnson Lau via bitcoin-dev wrote a workaround to replicate the original behavior of "DEPTH TOALTSTACK IFDUP DEPTH FROMALTSTACK NUMNOTEQUAL IF 2DROP {if script} ELSE DROP {else script} ENDIF" in Bitcoin. However, this workaround was deemed "much uglier than expected." Instead, OP_1 OP_EQUAL OP_IF should be used when avoiding malleability issues. OP_IF would accept any non-zero value, and examples where it would be used include HTLC scripts, BIP 124, BIP 65, and BIP 112. Since the conversation was taking place during a softfork activation with segwit, there was the possibility of adding new opcodes before version 0.13.1. Luke Dashjr suggested two potential candidates for new opcodes: OP_CASTTOBOOL and OP_DUPASBOOL. He also mentioned the possibility of an OP_RETAINIF opcode that would behave like the current OP_IF but not pop the conditional value off the stack. However, he noted that this might be too complicated to test in time for segwit.
Updated on: 2023-06-11T19:45:10.264807+00:00