Difference between revisions of "SIGHASH flags"
(Created page with "Signature checking is flexible because the form of transaction that is signed can be controlled through the use of SIGHASH flags, which are stuck on the end of a signature. In...") |
|||
Line 1: | Line 1: | ||
− | Signature checking is flexible because the form of transaction that is signed can be controlled through the use of SIGHASH flags, which are stuck on the end of a signature. In this way, contracts can be constructed in which each party signs only a part of it, allowing other parts to be changed without their involvement. The SIGHASH flags have two parts, a mode and the ANYONECANPAY modifier: | + | {| class="wikitable" |
+ | |- | ||
+ | ! Flag | ||
+ | ! Functional Meaning | ||
+ | |- | ||
+ | | SIGHASH_ALL | ||
+ | | Sign all inputs and outputs | ||
+ | |- | ||
+ | | SIGHASH_SINGLE | ||
+ | | Sign all inputs and the output with the same index | ||
+ | |- | ||
+ | | SIGHASH_NONE | ||
+ | | Sign all inputs and no ouput | ||
+ | |- | ||
+ | | SIGHASH_ALL | ANYONECANPAY | ||
+ | | Sign its own input and all outputs | ||
+ | |- | ||
+ | | SIGHASH_SINGLE | ANYONECANPAY | ||
+ | | Sign its own input and the output with the same index | ||
+ | |- | ||
+ | | SIGHASH_NONE | ANYONECANPAY | ||
+ | | Sign its own input and no output | ||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | {| class="color" |}Signature checking is flexible because the form of transaction that is signed can be controlled through the use of SIGHASH flags, which are stuck on the end of a signature. In this way, contracts can be constructed in which each party signs only a part of it, allowing other parts to be changed without their involvement. The SIGHASH flags have two parts, a mode and the ANYONECANPAY modifier: | ||
SIGHASH_ALL: This is the default. It indicates that everything about the transaction is signed, except for the input scripts. Signing the input scripts as well would obviously make it impossible to construct a transaction, so they are always blanked out. Note, though, that other properties of the input, like the connected output and sequence numbers, are signed; it's only the scripts that are not. Intuitively, it means "I agree to put my money in, if everyone puts their money in and the outputs are this". | SIGHASH_ALL: This is the default. It indicates that everything about the transaction is signed, except for the input scripts. Signing the input scripts as well would obviously make it impossible to construct a transaction, so they are always blanked out. Note, though, that other properties of the input, like the connected output and sequence numbers, are signed; it's only the scripts that are not. Intuitively, it means "I agree to put my money in, if everyone puts their money in and the outputs are this". |
Revision as of 11:33, 15 November 2019
Flag | Functional Meaning |
---|---|
SIGHASH_ALL | Sign all inputs and outputs |
SIGHASH_SINGLE | Sign all inputs and the output with the same index |
SIGHASH_NONE | Sign all inputs and no ouput |
ANYONECANPAY | Sign its own input and all outputs |
ANYONECANPAY | Sign its own input and the output with the same index |
ANYONECANPAY | Sign its own input and no output |