MCPcopy Create free account
hub / github.com/ccxt/ccxt / sign

Method sign

python/ccxt/gemini.py:1855–1884  ·  view source on GitHub ↗
(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None)

Source from the content-addressed store, hash-verified

1853 return self.group_by(results, 'network')
1854
1855 def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None):
1856 url = '/' + self.implode_params(path, params)
1857 query = self.omit(params, self.extract_params(path))
1858 if api == 'private':
1859 self.check_required_credentials()
1860 apiKey = self.apiKey
1861 if apiKey.find('account') < 0:
1862 raise AuthenticationError(self.id + ' sign() requires an account-key, master-keys are not-supported')
1863 nonce = str(self.nonce())
1864 finalUrl = url
1865 request = self.extend({
1866 'request': finalUrl,
1867 'nonce': nonce,
1868 }, query)
1869 payload = self.json(request)
1870 payload = self.string_to_base64(payload)
1871 signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha384)
1872 headers = {
1873 'Content-Type': 'text/plain',
1874 'X-GEMINI-APIKEY': self.apiKey,
1875 'X-GEMINI-PAYLOAD': payload,
1876 'X-GEMINI-SIGNATURE': signature,
1877 }
1878 else:
1879 if query:
1880 url += '?' + self.urlencode(query)
1881 url = self.urls['api'][api] + url
1882 if (method == 'POST') or (method == 'DELETE'):
1883 body = self.json(query)
1884 return {'url': url, 'method': method, 'body': body, 'headers': headers}
1885
1886 def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
1887 if response is None:

Callers

nothing calls this directly

Calls 13

nonceMethod · 0.95
AuthenticationErrorClass · 0.90
implode_paramsMethod · 0.80
extract_paramsMethod · 0.80
findMethod · 0.80
string_to_base64Method · 0.80
omitMethod · 0.45
extendMethod · 0.45
jsonMethod · 0.45
hmacMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected