Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: oleganza on August 13, 2013, 06:27:29 PM



Title: OP_VERIF & OP_VERNOTIF opcodes
Post by: oleganza on August 13, 2013, 06:27:29 PM
I don't understand why the wiki says (https://en.bitcoin.it/wiki/Script):

OP_VERIF (0x65) Transaction is invalid even when occuring in an unexecuted OP_IF branch
OP_VERNOTIF (0x66) Transaction is invalid even when occuring in an unexecuted OP_IF branch

From the BitcoinQT code I see that OP_VERIF and OP_VERNOTIF are undefined in the same way as OP_VER or OP_RESERVED. Meaning, if OP_VER is skipped in the if branch, then OP_VERIF is skipped as well.

But the wiki says that tx will be valid if OP_VER is not executed, but will be invalid even if OP_VERIF is not executed. Is it a mistake in the wiki or I miss something here?



Title: Re: OP_VERIF & OP_VERNOTIF opcodes
Post by: oleganza on August 18, 2013, 12:29:38 PM
Now I know why OP_VERIF and OP_VERNOTIF fail the transaction even if "not executed".

BitcoinQT walks though all operators from OP_IF to OP_ENDIF inside "non-executed" branch to keep track of nesting.
Since OP_VERIF and OP_VERNOTIF are not assigned, even inside a non-executed branch they will fall in "default:" switch case and cause the script to fail. Some other ops like OP_VER can be present inside non-executed branch because they'll be skipped.

Code:
    OP_IF       = 0x63, 
    OP_NOTIF    = 0x64,
    OP_VERIF    = 0x65, // Not assigned.
    OP_VERNOTIF = 0x66, // Not assigned.
    OP_ELSE     = 0x67,
    OP_ENDIF    = 0x68