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
sourceimpl Clone for WitnessSighashArgs
impl Clone for WitnessSighashArgs
sourcefn clone(&self) -> WitnessSighashArgs
fn clone(&self) -> WitnessSighashArgs
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for WitnessSighashArgs
impl Debug for WitnessSighashArgs
sourceimpl From<&WitnessSighashArgs> for LegacySighashArgs
impl From<&WitnessSighashArgs> for LegacySighashArgs
sourcefn from(s: &WitnessSighashArgs) -> Self
fn from(s: &WitnessSighashArgs) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<WitnessSighashArgs> for WitnessSighashArgs
impl PartialEq<WitnessSighashArgs> for WitnessSighashArgs
sourcefn eq(&self, other: &WitnessSighashArgs) -> bool
fn eq(&self, other: &WitnessSighashArgs) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &WitnessSighashArgs) -> bool
fn ne(&self, other: &WitnessSighashArgs) -> bool
This method tests for !=
.
impl Eq for WitnessSighashArgs
impl StructuralEq for WitnessSighashArgs
impl StructuralPartialEq for WitnessSighashArgs
Auto Trait Implementations
impl RefUnwindSafe for WitnessSighashArgs
impl Send for WitnessSighashArgs
impl Sync for WitnessSighashArgs
impl Unpin for WitnessSighashArgs
impl UnwindSafe for WitnessSighashArgs
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more