code: func getWitnessSigOps(pkScript []byte, witness wire.TxWitness) int {
  	// Attempt to extract the witness program version.
  	witnessVersion, witnessProgram, err := ExtractWitnessProgramInfo(
  		pkScript,
  	)
  	if err != nil {
  		return 0
  	}
  
  	switch witnessVersion {
  	case 0:
  		switch {
  		case len(witnessProgram) == payToWitnessPubKeyHashDataSize:
  			return 1
  		case len(witnessProgram) == payToWitnessScriptHashDataSize &&
  			len(witness) > 0:
  
  			witnessScript := witness[len(witness)-1]
  			pops, _ := parseScript(witnessScript)
  			return getSigOpCount(pops, true)
  		}
  	}
  
  	return 0
  }
docs: // getWitnessSigOps returns the number of signature operations generated by
  // spending the passed witness program wit the passed witness. The exact
  // signature counting heuristic is modified by the version of the passed
  // witness program. If the version of the witness program is unable to be
  // extracted, then 0 is returned for the sig op count.