code: func WitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int, amt int64,
  	subscript []byte, hashType SigHashType, privKey *btcec.PrivateKey,
  	compress bool) (wire.TxWitness, error) {
  
  	sig, err := RawTxInWitnessSignature(tx, sigHashes, idx, amt, subscript,
  		hashType, privKey)
  	if err != nil {
  		return nil, err
  	}
  
  	pk := (*btcec.PublicKey)(&privKey.PublicKey)
  	var pkData []byte
  	if compress {
  		pkData = pk.SerializeCompressed()
  	} else {
  		pkData = pk.SerializeUncompressed()
  	}
  
  	// A witness script is actually a stack, so we return an array of byte
  	// slices here, rather than a single byte slice.
  	return wire.TxWitness{sig, pkData}, nil
  }
docs: // WitnessSignature creates an input witness stack for tx to spend BTC sent
  // from a previous output to the owner of privKey using the p2wkh script
  // template. The passed transaction must contain all the inputs and outputs as
  // dictated by the passed hashType. The signature generated observes the new
  // transaction digest algorithm defined within BIP0143.