I don't understand what the 'ScriptCode' thing is. Is it a part of transaction format? The wiki https://en.bitcoin.it/wiki/Transaction describes scriptPubKey and scriptSig, mentioning nothing about 'ScriptCode'.
When viewing an example P2WPKH transaction here http://n.bitcoin.ninja/checktx?txid=d869f854e1f8788bcff294cc83b280942a8c728de71eb709a2c29d10bfe21b7c
The "Script Code" field is displayed as "OP_DUP OP_HASH160 1d7cd6c75c2e86f4cbf98eaed221b30bd9a0b928 OP_EQUALVERIFY OP_CHECKSIG"(so the standard script used by ordinary P2PKH transactions), but these are not given by scriptSig or scriptPubKey(obviously, since those two have a very specific form required for SegWit transactions). Can someone explain where this stuff comes from?