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.

3

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

  • 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 Apr 26 '16 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.