user100290: I have script to create a P2WPKH to P2WPKH transaction (1 input, 1 output) and sign it with the sighash type 0x01 SIGHASH_ALL.
Which fields would I need to change in the tx digest preimage to turn the signature into one with a sighash type of 0x83 (SINGLE|ANYONECANPAY)? I'm having trouble understanding the documentation in bip_143.
For reference, the tx digest preimage:

Double SHA256 of the serialization of:
       1. nVersion of the transaction (4-byte little endian)
       2. hashPrevouts (32-byte hash)
       3. hashSequence (32-byte hash)
       4. outpoint (32-byte hash + 4-byte little endian) 
       5. scriptCode of the input (serialized as scripts inside CTxOuts)
       6. value of the output spent by this input (8-byte little endian)
       7. nSequence of the input (4-byte little endian)
       8. hashOutputs (32-byte hash)
       9. nLocktime of the transaction (4-byte little endian)
      10. sighash type of the signature (4-byte little endian)


user3667: From BIP143:

If the ANYONECANPAY flag is not set, hashPrevouts is the double SHA256
  of the serialization of all input outpoints;
Otherwise, hashPrevouts is a uint256 of 0x0000......0000.

All the details you need are in the BIP

100290: <p>I have script to create a P2WPKH to P2WPKH transaction (1 input, 1 output) and sign it with the sighash type 0x01 SIGHASH_ALL.</p>

<p>Which fields would I need to change in the tx digest preimage to turn the signature into one with a sighash type of 0x83 (SINGLE|ANYONECANPAY)? I'm having trouble understanding the documentation in bip_143.</p>

<p>For reference, the tx digest preimage:</p>

<blockquote>
  <p>Double SHA256 of the serialization of:<br>
       1. nVersion of the transaction (4-byte little endian)<br>
       2. hashPrevouts (32-byte hash)<br>
       3. hashSequence (32-byte hash)<br>
       4. outpoint (32-byte hash + 4-byte little endian) <br>
       5. scriptCode of the input (serialized as scripts inside CTxOuts)<br>
       6. value of the output spent by this input (8-byte little endian)<br>
       7. nSequence of the input (4-byte little endian)<br>
       8. hashOutputs (32-byte hash)<br>
       9. nLocktime of the transaction (4-byte little endian)<br>
      10. sighash type of the signature (4-byte little endian)<br></p>
</blockquote>
 3667: <p>From BIP143:</p>

<blockquote>
  <p>If the ANYONECANPAY flag is not set, hashPrevouts is the double SHA256
  of the serialization of all input outpoints;</p>
  
  <p>Otherwise, hashPrevouts is a uint256 of 0x0000......0000.</p>
</blockquote>

<p>All the details you need are in the BIP</p>
