Struct bitcoins::types::legacy::LegacySighashArgs [−][src]
pub struct LegacySighashArgs {
pub index: usize,
pub sighash_flag: Sighash,
pub prevout_script: Script,
}
Expand description
Arguments required to serialize the transaction to create the sighash digest.Used in
legacy_sighash
to abstract the sighash serialization logic from the hasher used.
SIGHASH_ALL commits to ALL inputs, and ALL outputs. It indicates that no further modification of the transaction is allowed without invalidating the signature.
SIGHASH_ALL + ANYONECANPAY commits to ONE input and ALL outputs. It indicates that anyone may add additional value to the transaction, but that no one may modify the payments made. Any extra value added above the sum of output values will be given to miners as part of the tx fee.
SIGHASH_SINGLE commits to ALL inputs, and ONE output. It indicates that anyone may append additional outputs to the transaction to reroute funds from the inputs. Additional inputs cannot be added without invalidating the signature. It is logically difficult to use securely, as it consents to funds being moved, without specifying their destination.
SIGHASH_SINGLE commits specifically the the output at the same index as the input being signed. If there is no output at that index, (because, e.g. the input vector is longer than the output vector) it behaves insecurely, and we do not implement that protocol bug.
SIGHASH_SINGLE + ANYONECANPAY commits to ONE input and ONE output. It indicates that anyone may add additional value to the transaction, and route value to any other location. The signed input and output must be included in the fully-formed transaction at the same index in their respective vectors.
For Legacy sighash documentation, see here:
- https://en.bitcoin.it/wiki/OP_CHECKSIG#Hashtype_SIGHASH_ALL_.28default.29
Note
After signing the digest, you MUST append the sighash indicator byte to the resulting signature.
Fields
index: usize
The index of the input we’d like to sign
sighash_flag: Sighash
The sighash mode to use.
prevout_script: Script
The script used in the prevout, which must be signed. In complex cases involving
OP_CODESEPARATOR
this must be the subset of the script containing the OP_CHECKSIG
currently being executed.
Trait Implementations
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for LegacySighashArgs
impl Send for LegacySighashArgs
impl Sync for LegacySighashArgs
impl Unpin for LegacySighashArgs
impl UnwindSafe for LegacySighashArgs
Blanket Implementations
Mutably borrows from an owned value. Read more