pub struct WitnessSighashArgs {
    pub index: usize,
    pub sighash_flag: Sighash,
    pub prevout_script: Script,
    pub prevout_value: u64,
}
Expand description

Arguments required to serialize the transaction to create the BIP143 (witness) sighash digest. Used in witness_sighash to abstract the sighash serialization logic from the hash 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 BIP143 sighash documentation, see here:

  • https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki

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.

prevout_value: u64

The value of the prevout.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.