pub struct Credential { /* private fields */ }Expand description
Lighter API credentials required for authenticated REST, private WebSocket, and L2 transaction signing.
Lighter identifies API keys by numeric index. The API private key signs both
auth tokens and L2 transactions for (account_index, api_key_index).
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn new(
api_key_index: u8,
api_secret: impl Into<String>,
account_index: u64,
) -> Result<Self>
pub fn new( api_key_index: u8, api_secret: impl Into<String>, account_index: u64, ) -> Result<Self>
Creates a new Credential instance from a key index, private key, and
account index.
§Errors
Returns an error if account_index exceeds the signed range used by the
Lighter signer or if api_secret is not a 40-byte hex private key.
Sourcepub fn resolve(
private_key: Option<String>,
account_index: Option<u64>,
api_key_index: Option<u8>,
environment: LighterEnvironment,
) -> Result<Option<Self>>
pub fn resolve( private_key: Option<String>, account_index: Option<u64>, api_key_index: Option<u8>, environment: LighterEnvironment, ) -> Result<Option<Self>>
Resolves credentials from provided config values or environment variables.
Config values take precedence, but a blank or whitespace-only
private_key falls back to the environment variable. Environment
variables follow credential_env_vars. LIGHTER_API_KEY_INDEX is
the per-account API key slot (0..=254), separate from any hex public
key the venue reports for that slot.
§Errors
Returns an error if any resolved numeric field cannot be parsed, if the account index exceeds the signed range, or if the API private key is not valid 40-byte hex.
Sourcepub const fn api_key_index(&self) -> u8
pub const fn api_key_index(&self) -> u8
Returns the Lighter API key index.
Sourcepub const fn account_index(&self) -> i64
pub const fn account_index(&self) -> i64
Returns the Lighter account index.
Sourcepub fn private_key(&self) -> Result<PrivateKey>
pub fn private_key(&self) -> Result<PrivateKey>
Decodes the API private key for Lighter signing.
§Errors
Returns an error if the secret is not 40-byte hex, with or without a
0x prefix.
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Credential
impl Debug for Credential
Source§impl Drop for Credential
impl Drop for Credential
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnsafeUnpin for Credential
impl UnwindSafe for Credential
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more