(self, path, api: Any = [], method='GET', params={}, headers: dict = None, body: Str = None)
| 4860 | return None |
| 4861 | |
| 4862 | def sign(self, path, api: Any = [], method='GET', params={}, headers: dict = None, body: Str = None): |
| 4863 | signed = api[0] == 'private' |
| 4864 | endpoint = api[1] |
| 4865 | request = '/' + self.implode_params(path, params) |
| 4866 | payload = None |
| 4867 | if (endpoint == 'spot') or (endpoint == 'user'): |
| 4868 | if signed: |
| 4869 | payload = '/' + self.version + request |
| 4870 | else: |
| 4871 | payload = '/' + self.version + '/public' + request |
| 4872 | else: |
| 4873 | payload = request |
| 4874 | url = self.urls['api'][endpoint] + payload |
| 4875 | query = self.omit(params, self.extract_params(path)) |
| 4876 | urlencoded = self.urlencode(self.keysort(query)) |
| 4877 | headers = { |
| 4878 | 'Content-Type': 'application/json', |
| 4879 | } |
| 4880 | if signed: |
| 4881 | self.check_required_credentials() |
| 4882 | defaultRecvWindow = self.safe_string(self.options, 'recvWindow') |
| 4883 | recvWindow = self.safe_string(query, 'recvWindow', defaultRecvWindow) |
| 4884 | timestamp = self.number_to_string(self.nonce()) |
| 4885 | body = query |
| 4886 | if (payload == '/v4/order') or (payload == '/future/trade/v1/order/create') or (payload == '/future/trade/v1/entrust/create-plan') or (payload == '/future/trade/v1/entrust/create-profit') or (payload == '/future/trade/v1/order/create-batch'): |
| 4887 | id = 'CCXT' |
| 4888 | if payload.find('future') > -1: |
| 4889 | body['clientMedia'] = id |
| 4890 | else: |
| 4891 | body['media'] = id |
| 4892 | isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}') or (path == 'ws-token')) |
| 4893 | if (method == 'PUT') and (endpoint == 'spot'): |
| 4894 | isUndefinedBody = False |
| 4895 | body = None if isUndefinedBody else self.json(body) |
| 4896 | payloadString = None |
| 4897 | if (endpoint == 'spot') or (endpoint == 'user'): |
| 4898 | payloadString = 'xt-validate-algorithms=HmacSHA256&xt-validate-appkey=' + self.apiKey + '&xt-validate-recvwindow=' + recvWindow + '&xt-validate-t' + 'imestamp=' + timestamp |
| 4899 | if isUndefinedBody: |
| 4900 | if urlencoded: |
| 4901 | url += '?' + urlencoded |
| 4902 | payloadString += '#' + method + '#' + payload + '#' + self.rawencode(self.keysort(query)) |
| 4903 | else: |
| 4904 | payloadString += '#' + method + '#' + payload |
| 4905 | else: |
| 4906 | payloadString += '#' + method + '#' + payload + '#' + body |
| 4907 | headers['xt-validate-algorithms'] = 'HmacSHA256' |
| 4908 | headers['xt-validate-recvwindow'] = recvWindow |
| 4909 | else: |
| 4910 | payloadString = 'xt-validate-appkey=' + self.apiKey + '&xt-validate-t' + 'imestamp=' + timestamp # we can't glue timestamp, breaks in php |
| 4911 | if method == 'GET': |
| 4912 | if urlencoded: |
| 4913 | url += '?' + urlencoded |
| 4914 | payloadString += '#' + payload + '#' + urlencoded |
| 4915 | else: |
| 4916 | payloadString += '#' + payload |
| 4917 | else: |
| 4918 | payloadString += '#' + payload + '#' + body |
| 4919 | signature = self.hmac(self.encode(payloadString), self.encode(self.secret), hashlib.sha256) |
nothing calls this directly
no test coverage detected