code: func UnmarshalEnvelopeOfType(envelope *cb.Envelope, headerType cb.HeaderType, message proto.Message) (*cb.ChannelHeader, error) {
  	payload, err := UnmarshalPayload(envelope.Payload)
  	if err != nil {
  		return nil, err
  	}
  
  	if payload.Header == nil {
  		return nil, errors.New("envelope must have a Header")
  	}
  
  	chdr, err := UnmarshalChannelHeader(payload.Header.ChannelHeader)
  	if err != nil {
  		return nil, err
  	}
  
  	if chdr.Type != int32(headerType) {
  		return nil, errors.Errorf("invalid type %s, expected %s", cb.HeaderType(chdr.Type), headerType)
  	}
  
  	err = proto.Unmarshal(payload.Data, message)
  	err = errors.Wrapf(err, "error unmarshaling message for type %s", headerType)
  	return chdr, err
  }
docs: // UnmarshalEnvelopeOfType unmarshals an envelope of the specified type,
  // including unmarshaling the payload data