pub(crate) fn sighash(
    trans: &Transaction,
    hash_type: HashType,
    network_upgrade: NetworkUpgrade,
    input: Option<(&transparent::Output, &transparent::Input, usize)>,
) -> SigHash {
    let alt_tx = convert_tx_to_librustzcash(trans, network_upgrade)
        .expect("zcash_primitives and Zebra transaction formats must be compatible");

    let script: zcash_primitives::legacy::Script;
    let signable_input = match input {
        Some((output, _, idx)) => {
            script = (&output.lock_script).into();
            zcash_primitives::transaction::sighash::SignableInput::Transparent(
                zcash_primitives::transaction::sighash::TransparentInput::new(
                    idx,
                    &script,
                    output
                        .value
                        .try_into()
                        .expect("amount was previously validated"),
                ),
            )
        }
        None => zcash_primitives::transaction::sighash::SignableInput::Shielded,
    };

    let txid_parts = alt_tx
        .deref()
        .digest(zcash_primitives::transaction::txid::TxIdDigester);

    SigHash(
        *zcash_primitives::transaction::sighash::signature_hash(
            alt_tx.deref(),
            hash_type.bits(),
            &signable_input,
            &txid_parts,
        )
        .as_ref(),
    )
}
/// Compute a signature hash using librustzcash.
///
/// # Inputs
///
/// - `transaction`: the transaction whose signature hash to compute.
/// - `hash_type`: the type of hash (SIGHASH) being used.
/// - `network_upgrade`: the network upgrade of the block containing the transaction.
/// - `input`: information about the transparent input for which this signature
///     hash is being computed, if any. A tuple with the matching output of the
///     previous transaction, the input itself, and the index of the input in
///     the transaction.
Compute a signature hash using librustzcash.
Compute a signature hash using librustzcash .
pub(crate) fn sighash(
    trans: &Transaction,
    hash_type: HashType,
    network_upgrade: NetworkUpgrade,
    input: Option<(&transparent::Output, &transparent::Input, usize)>,
) -> SigHash {
    let alt_tx = convert_tx_to_librustzcash(trans, network_upgrade)
        .expect("zcash_primitives and Zebra transaction formats must be compatible");
    let script: zcash_primitives::legacy::Script;
    let signable_input = match input {
        Some((output, _, idx)) => {
            script = (&output.lock_script).into();
            zcash_primitives::transaction::sighash::SignableInput::Transparent(
                zcash_primitives::transaction::sighash::TransparentInput::new(
                    idx,
                    &script,
                    output
                        .value
                        .try_into()
                        .expect("amount was previously validated"),
                ),
            )
        }
        None => zcash_primitives::transaction::sighash::SignableInput::Shielded,
    };
    let txid_parts = alt_tx
        .deref()
        .digest(zcash_primitives::transaction::txid::TxIdDigester);
    SigHash(
        *zcash_primitives::transaction::sighash::signature_hash(
            alt_tx.deref(),
            hash_type.bits(),
            &signable_input,
            &txid_parts,
        )
        .as_ref(),
    )
}
pub ( crate ) fn sighash ( trans : & Transaction , hash_type : HashType , network_upgrade : NetworkUpgrade , input : Option < ( & transparent :: Output , & transparent :: Input , usize ) > , ) -> SigHash { let alt_tx = convert_tx_to_librustzcash ( trans , network_upgrade ) . expect ( " " ) ; let script : zcash_primitives :: legacy :: Script ; let signable_input = match input { Some ( ( output , _ , idx ) ) => { script = ( & output . lock_script ) . into ( ) ; zcash_primitives :: transaction :: sighash :: SignableInput :: Transparent ( zcash_primitives :: transaction :: sighash :: TransparentInput :: new ( idx , & script , output . value . try_into ( ) . expect ( " " ) , ) , ) } None => zcash_primitives :: transaction :: sighash :: SignableInput :: Shielded , } ; let txid_parts = alt_tx . deref ( ) . digest ( zcash_primitives :: transaction :: txid :: TxIdDigester ) ; SigHash ( * zcash_primitives :: transaction :: sighash :: signature_hash ( alt_tx . deref ( ) , hash_type . bits ( ) , & signable_input , & txid_parts , ) . as_ref ( ) , ) }
Compute a signature hash using librustzcash.
Compute a signature hash using librustzcash .
trans
&Transaction
hash_type
HashType
network_upgrade
NetworkUpgrade
input
Option<(&transparent::Output, &transparent::Input, usize)>
inputs
`transaction`: the transaction whose signature hash to compute.
`hash_type`: the type of hash (SIGHASH) being used.
`network_upgrade`: the network upgrade of the block containing the transaction.
`input`: information about the transparent input for which this signature
hash is being computed, if any. A tuple with the matching output of the
previous transaction, the input itself, and the index of the input in
the transaction.
` transaction ` : the transaction whose signature hash to compute . ` hash_type ` : the type of hash ( SIGHASH ) being used . ` network_upgrade ` : the network upgrade of the block containing the transaction . ` input ` : information about the transparent input for which this signature hash is being computed if any . A tuple with the matching output of the previous transaction the input itself and the index of the input in the transaction .