Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ThePiachu on January 02, 2012, 12:29:30 AM



Title: OP_IF and related ops - any examples?
Post by: ThePiachu on January 02, 2012, 12:29:30 AM
I'm currently having some problems trying to envision how OP_IF, OP_ELSE and OP_ENDIF would be processed in Script. Does anyone have some examples, documentation or unit tests relating to their functionality?

I understand that when the application is processing the script and encounters OP_IF, it pops the top item from the stack, check whether it evaluated to true, and then processes the script until OP_ELSE (in case it is true), then skips everything between OP_ELSE to OP_ENDIF. But without actually evaluating what is between those two operations, some hex that would represent a number accidentally evaluate to OP_ENDIF and finish the operation early. How is this problem solved?


Title: Re: OP_IF and related ops - any examples?
Post by: Mike Hearn on January 04, 2012, 06:31:11 PM
Data chunks are length prefixed.