Bitcoin Forum
December 02, 2016, 06:26:13 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: OP_IF and related ops - any examples?  (Read 782 times)
ThePiachu
Sr. Member
****
Offline Offline

Activity: 442



View Profile WWW
January 02, 2012, 12:29:30 AM
 #1

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?

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
1480703173
Hero Member
*
Offline Offline

Posts: 1480703173

View Profile Personal Message (Offline)

Ignore
1480703173
Reply with quote  #2

1480703173
Report to moderator
1480703173
Hero Member
*
Offline Offline

Posts: 1480703173

View Profile Personal Message (Offline)

Ignore
1480703173
Reply with quote  #2

1480703173
Report to moderator
1480703173
Hero Member
*
Offline Offline

Posts: 1480703173

View Profile Personal Message (Offline)

Ignore
1480703173
Reply with quote  #2

1480703173
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480703173
Hero Member
*
Offline Offline

Posts: 1480703173

View Profile Personal Message (Offline)

Ignore
1480703173
Reply with quote  #2

1480703173
Report to moderator
1480703173
Hero Member
*
Offline Offline

Posts: 1480703173

View Profile Personal Message (Offline)

Ignore
1480703173
Reply with quote  #2

1480703173
Report to moderator
Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526


View Profile
January 04, 2012, 06:31:11 PM
 #2

Data chunks are length prefixed.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!