Bitcoin Forum
November 16, 2024, 04:47:48 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: redundant opcodes in script?  (Read 598 times)
Cryddit (OP)
Legendary
*
Offline Offline

Activity: 924
Merit: 1132


View Profile
April 01, 2014, 03:05:10 AM
 #1


Script has unnamed opcodes from 0x01 to 0x4b whose semantics are that the values are simply pushed onto the stack.

Then it has OP_1 (aka OP_TRUE) through OP_16 from 0x51 through Ox60 whose semantics are that the values from 1 to 16 (a subrange of the above) are pushed onto the stack. 

0x51 through 0x60 repeat exactly the semantics of 0x01 through 0x10.

What is the rationale for not having simply given the names OP_1 through OP_16 to the codes 0x01 through 0x10?  Would anything work differently if the 0x51 through 0x60 range were reserved and completely unused? 

Cryddit
uminatsu
Jr. Member
*
Offline Offline

Activity: 55
Merit: 2


View Profile
April 01, 2014, 03:26:57 AM
 #2

The semantics are different. 0x53 pushes numer "3" while 0x03 indicates that the 3 bytes following it are pushed as one entity.
Cryddit (OP)
Legendary
*
Offline Offline

Activity: 924
Merit: 1132


View Profile
April 01, 2014, 03:45:34 AM
 #3

No...  I'm looking straight at the code now.

0x03 and 0x53 both push the value '3' onto the stack.  They are the same.

0x4d aka OP_PUSHDATA2 means 'the next 2 bytes contain a number of following bytes to be pushed onto the stack' and 0x04e aka OP_PUSHDATA4 is the same thing for 4 bytes. 

If you wanted to push a 3-byte number onto the stack as a unit, you'd write

OP_PUSHDATA1, 0x03, DATA1, DATA2, DATA3



etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
April 01, 2014, 04:04:50 AM
 #4

no, 0x03 says "the next three bytes will be pushed onto the stack as a single object", then it reads and pushes those three bytes... the 3 itself is not pushed.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
Cryddit (OP)
Legendary
*
Offline Offline

Activity: 924
Merit: 1132


View Profile
April 01, 2014, 04:45:44 AM
 #5

Hrm.

On closer inspection of what the code actually does, you are right and the comment I was looking at is wrong. 

Thank you. 


instagibbs
Member
**
Offline Offline

Activity: 114
Merit: 12


View Profile
April 01, 2014, 06:41:09 PM
 #6

Glad it got figured out. The opcodes section can be quite confusing. Hopefully the Dev Guide ends up being clearer.

The multisig scenario is where this shows itself: Before each key in the script you have to append 0x21(push the 40 byte pub key on the stack) and when choosing m-of-n you use 0x51~whatever.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!