code: func RawTxInWitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int,
  	amt int64, subScript []byte, hashType SigHashType,
  	key *btcec.PrivateKey) ([]byte, error) {
  
  	parsedScript, err := parseScript(subScript)
  	if err != nil {
  		return nil, fmt.Errorf("cannot parse output script: %v", err)
  	}
  
  	hash, err := calcWitnessSignatureHash(parsedScript, sigHashes, hashType, tx,
  		idx, amt)
  	if err != nil {
  		return nil, err
  	}
  
  	signature, err := key.Sign(hash)
  	if err != nil {
  		return nil, fmt.Errorf("cannot sign tx input: %s", err)
  	}
  
  	return append(signature.Serialize(), byte(hashType)), nil
  }
docs: // RawTxInWitnessSignature returns the serialized ECDA signature for the input
  // idx of the given transaction, with the hashType appended to it. This
  // function is identical to RawTxInSignature, however the signature generated
  // signs a new sighash digest defined in BIP0143.