Author

Topic: redundant opcodes in script? (Read 598 times)

member
Activity: 114
Merit: 12
April 01, 2014, 01: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.
legendary
Activity: 924
Merit: 1132
March 31, 2014, 11:45:44 PM
#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. 


legendary
Activity: 1428
Merit: 1093
Core Armory Developer
March 31, 2014, 11:04:50 PM
#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.
legendary
Activity: 924
Merit: 1132
March 31, 2014, 10:45:34 PM
#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



jr. member
Activity: 55
Merit: 2
March 31, 2014, 10:26:57 PM
#2
The semantics are different. 0x53 pushes numer "3" while 0x03 indicates that the 3 bytes following it are pushed as one entity.
legendary
Activity: 924
Merit: 1132
March 31, 2014, 10:05:10 PM
#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
Jump to: