New BIP: Dealing with OP_IF and OP_NOTIF malleability in P2WSH [combined summary]



Individual post summaries: Click here to read the original discussion on the lightning-dev mailing list

Published on: 2016-09-05T01:32:19+00:00


Summary:

Johnson Lau, a user on the bitcoin-dev forum, has proposed a restriction for the segwit OP_IF argument as policy. He is looking for feedback from users of OP_IF, especially those who are using it in real-world applications like the Lightning network. Another user, Rusty, mentions that his current scripts use OP_IF and OP_NOTIF only after OP_EQUAL, except for one instance where they use OP_EQUAL...OP_EQUAL...OP_ADD OP_IF. However, he states that this does not have any impact on the c-lightning implementation.To address the malleability issue with OP_IF and OP_NOTIF in pay-to-witness-script-hash (P2WSH) scripts, a new BIP (Bitcoin Improvement Proposal) has been prepared. The proposed changes will only apply to P2WSH scripts described in BIP141, which has not yet been activated on the Bitcoin mainnet. In order to ensure that transactions using OP_IF and OP_NOTIF created before the introduction of this BIP will still be accepted by the network, the new rules will not be applied to non-segregated witness scripts.Under the new rules, in P2WSH, the argument for OP_IF and OP_NOTIF must be either an empty vector or 0x01. If the argument does not meet these criteria, the script evaluation fails immediately. This is considered a softfork on top of BIP141. The rules have been enforced as a relay policy by the reference client since the initial release of BIP141 (v0.13.1).There may be compatibility issues if your script uses the combination of "OP_SIZE OP_IF" or "OP_DEPTH OP_IF". To comply with this new policy/softfork, you will need to use "OP_SIZE OP_0NOTEQUAL OP_IF" or "OP_DEPTH OP_0NOTEQUAL OP_IF", or modify your scripts accordingly.For more in-depth discussions on this topic, you can refer to the following link: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2016-August/013036.html.


Updated on: 2023-07-31T19:11:25.370884+00:00