Skip to content

Binance - support ed25519 keys #22965

@xmatthias

Description

@xmatthias

Operating System

linux

Programming Languages

Python

CCXT Version

4.3.54

Description

Using RSA keys with ccxt is be possible - though using ed25519 (which are slightly newer) seems to be impossible.
This apparently came up already in #18876 - though i can't see that it's been adressed - and it's clearly not working currently.

Using a valid ed25519 key yields a plain error ... so this seems to either not be supported currently - or it's somehow expecting a different format (not .pem).

Code

import ccxt
exchange = ccxt.binance({
    'apiKey': '<APIKEY>', 
    'secret': '-----BEGIN PRIVATE KEY-----\n<APISECRET>\n-----END PRIVATE KEY-----', 
    })
exchange.check_required_credentials()
_ = exchange.load_markets()  # <-- fails
TypeError: argument 'data': from_buffer() cannot return the address of a unicode object
Full Error output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/base/exchange.py", line 1539, in load_markets
    currencies = self.fetch_currencies()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/binance.py", line 2636, in fetch_currencies
    response = self.sapiGetCapitalConfigGetall(params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/base/types.py", line 35, in unbound_method
    return _self.request(self.path, self.api, self.method, params, config=self.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/binance.py", line 10419, in request
    response = self.fetch2(path, api, method, params, headers, body, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/base/exchange.py", line 3733, in fetch2
    request = self.sign(path, api, method, params, headers, body)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/binance.py", line 10297, in sign
    signature = self.encode_uri_component(self.eddsa(self.encode(query), self.secret, 'ed25519'))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xmatt/.pyenv/versions/trade_3122/lib/python3.12/site-packages/ccxt/base/exchange.py", line 1453, in eddsa
    private_key = ed25519.Ed25519PrivateKey.from_private_bytes(secret) if len(secret) == 32 else load_pem_private_key(secret, None)
                                                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument 'data': from_buffer() cannot return the address of a unicode object

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions