Difference between revisions of "SIGHASH flags"
| Line 31: | Line 31: | ||
| Sign its own input and the output with the same index | | Sign its own input and the output with the same index | ||
|} | |} | ||
| + | |||
| + | The table below illustrates what is signed and what is not signed in a more granulated detail by an ECDSA siganture in the Input 1 in a transaction. | ||
{| class="wikitable" | {| class="wikitable" | ||
| + | |- | ||
| + | | | ||
| + | | ALL | ||
| + | | NONE | ||
| + | | SINGLE | ||
| + | | ALL <nowiki>|</nowiki> ANYONECANPAY | ||
| + | | NONE <nowiki>|</nowiki> ANYONECANPAY | ||
| + | | SINGLE <nowiki>|</nowiki> ANYONECANPAY | ||
|- | |- | ||
| Version | | Version | ||
| − | | | + | | Yes |
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | |- | ||
| Locktime | | Locktime | ||
| − | | | + | | Yes |
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
|- | |- | ||
| − | | | + | | Input 1 outpoint |
| − | | | + | | Yes |
| − | | | + | | Yes |
| − | | | + | | Yes |
| − | | | + | | Yes |
| + | | Yes | ||
| + | | Yes | ||
|- | |- | ||
| − | | | + | | Input 1 scriptSig |
| − | | | + | | No |
| − | | | + | | No |
| + | | No | ||
| + | | No | ||
| + | | No | ||
| + | | No | ||
|- | |- | ||
| − | | | + | | Input 1 sequence number |
| − | | | + | | Yes |
| − | | | + | | Yes |
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
|- | |- | ||
| − | | | + | | Input 2 outpoint |
| − | | | + | | Yes |
| − | | | + | | Yes |
| + | | Yes | ||
| + | | No | ||
| + | | No | ||
| + | | No | ||
|- | |- | ||
| − | | | + | | Input 2 scriptSig |
| − | | | + | | No |
| − | | | + | | No |
| + | | No | ||
| + | | No | ||
| + | | No | ||
| + | | No | ||
| + | |- | ||
| + | | Input 2 sequence number | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | No | ||
| + | | No | ||
| + | | No | ||
| + | |- | ||
| + | | Output 1 | ||
| + | | Yes | ||
| + | | No | ||
| + | | Yes | ||
| + | | Yes | ||
| + | | No | ||
| + | | Yes | ||
| + | |- | ||
| + | | Output 2 | ||
| + | | Yes | ||
| + | | No | ||
| + | | No | ||
| + | | Yes | ||
| + | | No | ||
| + | | No | ||
|} | |} | ||
| + | Note that the version number and locktime are always signed, and the scriptSigs are never signed. | ||
| + | Use Case 1 - crowdfunding | ||
| − | + | Use Case 2 - blank check | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | Use Case 3 - Modular Transaction | |
| − | |||
| − | |||
| − | |||
==References== | ==References== | ||
https://github.com/bitcoin-sv/bitcoin-sv/blob/master/src/script/sighashtype.h | https://github.com/bitcoin-sv/bitcoin-sv/blob/master/src/script/sighashtype.h | ||
Revision as of 15:35, 21 November 2019
A SIGHASH flag is used to indicate which part of the transaction is signed by the ECDSA signature. The mechanism provides a flexibility in constructing transactions. There are in total 6 different flags that can be added to a digital signature in a transaction.
| Flag | Value | Functional Meaning |
|---|---|---|
| SIGHASH_ALL | 0x00000001 | Sign all inputs and outputs |
| SIGHASH_NONE | 0x00000002 | Sign all inputs and no output |
| SIGHASH_SINGLE | 0x00000003 | Sign all inputs and the output with the same index |
| SIGHASH_ALL | ANYONECANPAY | 0x00000081 | Sign its own input and all outputs |
| SIGHASH_NONE | ANYONECANPAY | 0x00000082 | Sign its own input and no output |
| SIGHASH_SINGLE | ANYONECANPAY | 0x00000083 | Sign its own input and the output with the same index |
The table below illustrates what is signed and what is not signed in a more granulated detail by an ECDSA siganture in the Input 1 in a transaction.
| ALL | NONE | SINGLE | ALL | ANYONECANPAY | NONE | ANYONECANPAY | SINGLE | ANYONECANPAY | |
| Version | Yes | Yes | Yes | Yes | Yes | Yes |
| Locktime | Yes | Yes | Yes | Yes | Yes | Yes |
| Input 1 outpoint | Yes | Yes | Yes | Yes | Yes | Yes |
| Input 1 scriptSig | No | No | No | No | No | No |
| Input 1 sequence number | Yes | Yes | Yes | Yes | Yes | Yes |
| Input 2 outpoint | Yes | Yes | Yes | No | No | No |
| Input 2 scriptSig | No | No | No | No | No | No |
| Input 2 sequence number | Yes | Yes | Yes | No | No | No |
| Output 1 | Yes | No | Yes | Yes | No | Yes |
| Output 2 | Yes | No | No | Yes | No | No |
Note that the version number and locktime are always signed, and the scriptSigs are never signed.
Use Case 1 - crowdfunding
Use Case 2 - blank check
Use Case 3 - Modular Transaction
References
https://github.com/bitcoin-sv/bitcoin-sv/blob/master/src/script/sighashtype.h