Skip to content

## Bug Report: SDK v1.0.2 Incompatible with Lighter API #103

Open

Description

@DiegorrQuant

Bug Report: SDK v1.0.2 Incompatible with Lighter API

Problem: All order operations fail with error code 21136

Error Message:

HTTP response body: code=21136 message='invalid PublicKey, update the sdk to the latest version'

Affected Operations:

  • create_market_order
  • create_sl_order
  • create_tp_order
  • create_order (all types)

SDK Version: 1.0.2 (latest from main branch)

Expected: Orders should be placed successfully

Actual: All orders fail with PublicKey validation error

Root Cause:
The Lighter API now requires a PublicKey field in transaction payloads, but SDK v1.0.2's compiled signer (lighter-signer-linux-amd64.so) doesn't include this field.

Request:
Please update the SDK and signer binary to include PublicKey field in all transaction types.

Workaround Needed:
Is there a temporary solution while waiting for SDK update?

Activity

  1. teamreputapro-sudo commented on Dec 22, 2025

    @teamreputapro-sudo

    ✅ Confirmed Fixed in SDK v1.0.2 (latest main branch)

    I was experiencing the same error 21136 "invalid PublicKey" and can confirm that the issue is resolved in the current SDK v1.0.2 on the main branch.

    What was the problem?

    The root cause was in the CreateAuthToken function. The old code passed only the deadline:

    CreateAuthToken(deadline)

    But it needed deadline + timestamp:

    CreateAuthToken(deadline + timestamp)

    This is now fixed in signer_client.py:

    result = self.signer.CreateAuthToken(deadline + timestamp, api_key_index, self.account_index)

    How to fix

    1. Clone the latest SDK from main:
    git clone https://github.com/elliottech/lighter-python.git
    cd lighter-python
    pip install -e .
    1. Important: Check for package conflicts!
      There's another PyPI package called lighter (a deep learning framework) that may conflict. Verify you're importing the correct one:
    import lighter
    print(lighter.__file__)  # Should point to the trading SDK, not /site-packages/lighter from the ML package

    If there's a conflict:

    pip uninstall lighter  # Remove the ML package if installed
    pip install -e /path/to/lighter-python  # Reinstall the trading SDK
    1. Updated SignerClient API:
      Note that v1.0.2 changed the constructor:
    # OLD (doesn't work):
    client = lighter.SignerClient.create_client(url, private_key, api_key_index, account_index)
    
    # NEW (v1.0.2):
    client = lighter.SignerClient(
        url=url,
        account_index=account_index,
        api_private_keys={api_key_index: api_key},  # Dict[int, str]
    )

    Verification

    After updating, verify with:

    client = lighter.SignerClient(url, account_index, {api_key_index: api_key})
    err = client.check_client()
    print("check_client:", "OK" if not err else err)
    
    token, err = client.create_auth_token_with_expiry(600)
    print("auth_token:", "OK" if not err else err)

    Both should return OK.

    Test Results

    I tested on mainnet with real orders:

    • ✅ ETH market buy (taker)
    • ✅ ETH market sell (taker)
    • ✅ SOL limit post-only (maker)
    • ✅ SOL market buy/sell

    All returned code 200.

    Hope this helps! The SDK is working correctly now.

  2. daedra86 commented on Dec 26, 2025

    @daedra86
    tx, tx_hash, error = await self.signer_client.update_leverage(
        market_index=market_id,
        margin_mode=margin_type,
        leverage=leverage,
        api_key_index=self.api_key_index,
    )
    

    I get the same error "HTTP response body: code=21136 message='invalid PublicKey, update the sdk to the latest version' additional_properties={}" on sdk version 1.0.2. This error appeared in version 1.0.1. I updated to version 1.0.2, but that didn't help. If I understand correctly, the API changed on the server side, but the fix was not added to the SDK.

    UPD: I recreated the API key and everything worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions