SIGHASH_ANYONECANPAY - Open Contribution Flag
14. SIGHASH_ANYONECANPAY — Open Contribution Flag
Overview
SIGHASH_ANYONECANPAY (value 0x80) is a modifier flag that, when combined with any base sighash type, causes the signature to commit only to the current input rather than all inputs. Other inputs can be freely added to the transaction without invalidating the signature.
SIGHASH_ANYONECANPAY = 0x80 (modifier)
Used as: SIGHASH_ALL | SIGHASH_ANYONECANPAY = 0x81
SIGHASH_NONE | SIGHASH_ANYONECANPAY = 0x82
SIGHASH_SINGLE | SIGHASH_ANYONECANPAY = 0x83
Effect on Input Serialization
def apply_anyonecanpay(tx_copy, input_index):
# Only include the current input (remove all others)
tx_copy.inputs = [tx_copy.inputs[input_index]]
# Output handling depends on the base sighash type
return tx_copy
The Key Property
A signature using SIGHASH_ANYONECANPAY says: "I authorize THIS input's funds to contribute to whatever transaction this ends up in, as long as the outputs match what I signed."
Without ANYONECANPAY:
Signature commits to [Input0, Input1, Input2, Output0, Output1]
→ Cannot add/remove inputs
With ANYONECANPAY:
Signature commits to [just Input1, Output0, Output1]
→ Inputs 0 and 2 can be anything; new inputs can be added freely
Crowdfunding Application
The canonical use case for SIGHASH_SINGLE | SIGHASH_ANYONECANPAY:
Goal: Fund a project that needs exactly 10 BTC to proceed.
If < 10 BTC is raised, nobody pays. If ≥ 10 BTC, everyone pays.
Protocol:
1. Project posts UTXO: "I'll add my 10 BTC output if anyone contributes"
→ Actually: Project posts a desired output: "Pay 10 BTC to <project_address>"
2. Contributors each create a partially-signed transaction:
Input: their UTXO (0.5 BTC, 1.0 BTC, etc.)
Signature type: SIGHASH_ALL | SIGHASH_ANYONECANPAY
→ Each contributor's sig commits to: their input + ALL outputs
3. When enough contributions are gathered, anyone can:
Combine all contributing inputs into one transaction
Include the output(s) the contributors signed for
Broadcast — all signatures remain valid!
4. If not enough contributions: no valid transaction can be formed
Contributors' funds stay safe — no partial settlement possible
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: