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.

1 Answer 1

3

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

1
  • 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
    Commented Apr 26, 2016 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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