How is "bytes to push" distinguishable in the scriptPubKey?

0

Trying to parse scriptPubKeys and get the individual opcodes. My question is: How would you identify the "bytes to push" values?

Here's an example of the typical scriptPubKey:

  76       A9             14
OP_DUP OP_HASH160    Bytes to push

89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG

bitcoin.it/wiki

Does "bytes to push" only occur after specific opcodes? Or is it that anything that doesn't correspond to an opcode is interpreted as indicating the upcoming number of bytes to push on to the stack?

Note: Basically any tips/advice on parsing the locking script would be handy.

inersha

Posted 2016-04-26T19:27:57.330

Reputation: 2 236

Answers

3

It appears that anything between 0x01 - 0x4b in the scriptPubKey signifies the number of bytes to be pushed on to the stack.

inersha

Posted 2016-04-26T19:27:57.330

Reputation: 2 236

Right. That's the most common type of push data opcode. However, there's also OP_PUSHDATA1, OP_PUSHDATA2, and (currently useless) OP_PUSHDATA4.Nick ODell 2016-04-26T19:40:30.197