Skip to main content
7 of 10
added 95 characters in body
Nick ODell
  • 29.5k
  • 11
  • 73
  • 132

These are the scriptPubKey's that are standard, arranged in order of popularity:

  1. P2PKH (Pay to public key hash)

     OP_DUP OP_HASH160 <20 bytes of public key hash> OP_EQUALVERIFY OP_CHECKSIG
    
  2. P2SH (Pay to script hash)

     OP_HASH160 <20 bytes of script hash> OP_EQUAL
    
  3. P2PK (Pay to public key)

This is now mostly unused, but there are still unspent outputs in the form:

    <33 or 65 bytes of public key> OP_CHECKSIG
  1. m-of-n bare multisig

Also pretty rare.

    <m> [n <public key>s] <n> OP_CHECKMULTISIG

Should I implement more sophisticated script parser which can detect "non-standard" scripts as well?

No. It's a waste of development time, when nobody uses transactions like that. (If they did, those transaction types would be added to the list of standard transactions. :)) It's also going to be very difficult to implement correctly. If you don't do it correctly, then you'll think you have coins when you really don't. For example, the transaction:

OP_DUP OP_HASH160 <20 bytes of public key hash> OP_2DROP OP_CHECKSIG

...is spendable by anybody, not just you. But does your script parser know that?

(Note that OP_EQUALVERIFY has been replaced by OP_2DROP in this example.)

Nick ODell
  • 29.5k
  • 11
  • 73
  • 132