def sighash(self, sighash_type, index=0, joinsplit=False, script_code=None,
                anyone_can_pay=False, prevout_value=None):
        '''
        ZIP243
        https://github.com/zcash/zips/blob/master/zip-0243.rst
        '''

        if joinsplit and anyone_can_pay:
            raise ValueError('ANYONECANPAY can\'t be used with joinsplits')

        data = z.ZcashByteData()

        data += self.header
        data += self.group_id

        data += self._hash_prevouts(anyone_can_pay)
        data += self._hash_sequence(sighash_type, anyone_can_pay)
        data += self._hash_outputs(sighash_type, index)
        data += self._hash_joinsplits()
        data += self._hash_shielded_spends()
        data += self._hash_shielded_outputs()

        data += self.lock_time
        data += self.expiry_height
        data += self.value_balance

        if anyone_can_pay:
            sighash_type = sighash_type | shared.SIGHASH_ANYONECANPAY
        data += utils.i2le_padded(sighash_type, 4)

        if not joinsplit:
            data += self.tx_ins[index].outpoint
            data += script_code
            data += prevout_value
            data += self.tx_ins[index].sequence

        return utils.blake2b(
            data=data.to_bytes(),
            digest_size=32,
            person=b'ZcashSigHash' + bytes.fromhex('bb09b876'))
ZIP243
        https://github.com/zcash/zips/blob/master/zip-0243.rst