What is a Standard vs Non-Standard Script
What is a Standard vs Non-Standard Script?
Bitcoin distinguishes between standard scripts and non-standard scripts. This distinction does not affect consensus validity — both types can appear in valid blocks — but it determines whether most nodes will relay a transaction through the peer-to-peer network.
Why the Distinction Exists
The Bitcoin P2P network uses relay policies to protect against spam and denial-of-service attacks. If any arbitrary script could be relayed freely, attackers could flood the network with complex, expensive-to-validate scripts. Standard script rules are a defense layer that predates the block size limit as a spam prevention mechanism.
The Five Original Standard Script Types
Bitcoin Core's IsStandard() function (in src/policy/policy.cpp) recognizes these output script types:
1. P2PK: <pubkey> OP_CHECKSIG
2. P2PKH: OP_DUP OP_HASH160 <hash> OP_EQUALVERIFY OP_CHECKSIG
3. P2SH: OP_HASH160 <hash> OP_EQUAL
4. P2WPKH: OP_0 <20-byte-hash>
5. P2WSH: OP_0 <32-byte-hash>
6. P2TR: OP_1 <32-byte-x-only-pubkey>
7. OP_RETURN: OP_RETURN <data up to 80 bytes> (data carrier)
8. Bare multisig: OP_M <pubkeys> OP_N OP_CHECKMULTISIG (limited)
What Happens to Non-Standard Scripts
If a transaction contains a non-standard script:
-
Default nodes will not relay it to their peers
-
It can still be mined — there is no consensus rule against non-standard scripts
-
Miners must receive it directly (out-of-band) to include it in a block
Some miners offer "non-standard transaction" services for a premium fee. Once a non-standard transaction is mined into a block, all nodes accept it as consensus-valid.
Checking Standardness
# Pseudocode for standardness check:
def is_standard_output(scriptPubKey):
if is_p2pkh(scriptPubKey): return True
if is_p2pk(scriptPubKey): return True
if is_p2sh(scriptPubKey): return True
if is_p2wpkh(scriptPubKey): return True
if is_p2wsh(scriptPubKey): return True
if is_p2tr(scriptPubKey): return True
if is_op_return(scriptPubKey): return True # data carrier
if is_bare_multisig(scriptPubKey):
return m <= 3 # Only up to 3-of-3 bare multisig
return False # Non-standard
The Evolution of Standard Scripts
The set of standard scripts has grown over time:
Each addition required a coordinated upgrade of Bitcoin Core's policy rules, separate from any consensus changes.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: