code: func (msg *MsgTx) WitnessHash() chainhash.Hash {
  	if msg.HasWitness() {
  		buf := bytes.NewBuffer(make([]byte, 0, msg.SerializeSize()))
  		_ = msg.Serialize(buf)
  		return chainhash.DoubleHashH(buf.Bytes())
  	}
  
  	return msg.TxHash()
  }
docs: // WitnessHash generates the hash of the transaction serialized according to
  // the new witness serialization defined in BIP0141 and BIP0144. The final
  // output is used within the Segregated Witness commitment of all the witnesses
  // within a block. If a transaction has no witness data, then the witness hash,
  // is the same as its txid.