SigHash Explained š
SigHash determines which parts of a Bitcoin transaction are signed.
This affects how the transaction can be modified by others after you sign it.
This affects how the transaction can be modified by others after you sign it.
There are 4 main types:
1. SIGHASH_ALL
Signs all inputs and all outputs.
This is the most common type, the entire transaction must remain unchanged for the signature to stay valid.
This is the most common type, the entire transaction must remain unchanged for the signature to stay valid.
2. SIGHASH_NONE
Signs all inputs, but no outputs.
This means someone else can change the outputs (e.g., the destination) without invalidating your signature.
ā ļø Use with caution!
This means someone else can change the outputs (e.g., the destination) without invalidating your signature.
ā ļø Use with caution!
3. SIGHASH_SINGLE
Signs all inputs, but only the output with the same index as the input being signed.
Useful for collaborative transactions where each participant only commits to their own output.
Useful for collaborative transactions where each participant only commits to their own output.
4. SIGHASH_ANYONECANPAY (modifier)
This is a flag that can be combined with the above types.
It makes the signature commit to only one input, allowing others to add more inputs to the transaction.
Example: Crowdfunding or shared transactions where multiple people contribute inputs.
It makes the signature commit to only one input, allowing others to add more inputs to the transaction.
Example: Crowdfunding or shared transactions where multiple people contribute inputs.