I see the following on bitcoin.it:


These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.

Word Opcode Hex Description
OP_PUBKEYHASH 253 0xfd Represents a public key hashed with OP_HASH160.
OP_PUBKEY 254 0xfe Represents a public key compatible with OP_CHECKSIG.
OP_INVALIDOPCODE 255 0xff Matches any opcode that is not yet assigned.

What is transaction matching?

How might these codes be used in practice?

  • 1
    I've edited the bitcoin.it page to drop the mention of these. They're confusing, outdated, and IMHO should never have been mentioned on that page to begin with as they were just an implementation detail and not part of the Bitcoin protocol. See my answer for why. Commented Apr 26 at 22:26

1 Answer 1


What is transaction matching?

When a wallet implementation is trying to figure out how to sign a script, it needs to figure out whether it's a script it knows how to sign for first. This can be very simple (e.g. only supporting P2PKH and P2WPKH spending), more complicated (e.g. spending a multisig output which needs gathering signatures from co-signers), or arbitrarily complex, depending on what the software is doing.

One approach for doing that is having a number of built-in "templates", which are not real scripts, but just patterns to match against. As an analogy, think of the word "telecommunication" matching the pattern "tel????muni??ion", where "?" means any letter. "tel????muni??ion" itself is not a word, but it can be used to match against words.

In a similar vein, a "script template" OP_DUP OP_HASH160 OP_PUBKEYHASH OP_EQUALVERIFY OP_CHECKSIG could be used to match P2PKH outputs. "OP_PUBKEYHASH" doesn't actually exist, it's just a placeholder for "anything that looks like a public key hash", just like "?" is not a letter but can be used to match against any letter.

How might these codes be used in practice?


It's an implementation detail used internally in some software, and not something you should know or care about as a user. In fact, Bitcoin Core since version 0.17.0 (released in October 2018) doesn't use this style of matching anymore, but an alternate approach that does not use templates or pseudo-opcodes.

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.