(self, path, api: Any = 'www', method='GET', params={}, headers: dict = None, body: Str = None)
| 1179 | return self.milliseconds() |
| 1180 | |
| 1181 | def sign(self, path, api: Any = 'www', method='GET', params={}, headers: dict = None, body: Str = None): |
| 1182 | urls = self.urls |
| 1183 | if not (api in urls['api']): |
| 1184 | raise ExchangeError(self.id + ' does not have a testnet/sandbox URL for ' + api + ' endpoints') |
| 1185 | if api != 'www': |
| 1186 | self.check_required_credentials() |
| 1187 | headers = { |
| 1188 | 'X-BITBNS-APIKEY': self.apiKey, |
| 1189 | } |
| 1190 | baseUrl = self.implode_hostname(self.urls['api'][api]) |
| 1191 | url = baseUrl + '/' + self.implode_params(path, params) |
| 1192 | query = self.omit(params, self.extract_params(path)) |
| 1193 | nonce = str(self.nonce()) |
| 1194 | if method == 'GET': |
| 1195 | if query: |
| 1196 | url += '?' + self.urlencode(query) |
| 1197 | elif method == 'POST': |
| 1198 | if query: |
| 1199 | body = self.json(query) |
| 1200 | else: |
| 1201 | body = '{}' |
| 1202 | auth = { |
| 1203 | 'timeStamp_nonce': nonce, |
| 1204 | 'body': body, |
| 1205 | } |
| 1206 | payload = self.string_to_base64(self.json(auth)) |
| 1207 | signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha512) |
| 1208 | headers = {} if (headers is None) else headers |
| 1209 | headers['X-BITBNS-PAYLOAD'] = payload |
| 1210 | headers['X-BITBNS-SIGNATURE'] = signature |
| 1211 | headers['Content-Type'] = 'application/x-www-form-urlencoded' |
| 1212 | return {'url': url, 'method': method, 'body': body, 'headers': headers} |
| 1213 | |
| 1214 | def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody): |
| 1215 | if response is None: |
nothing calls this directly
no test coverage detected