Skip to main content

IdentityStore

Struct IdentityStore 

Source
pub struct IdentityStore { /* private fields */ }
Expand description

Keystore for managing named Soroban identities.

Implementations§

Source§

impl IdentityStore

Source

pub fn new() -> Result<Self, StorageError>

Initialize the keystore in the default OS-portable config directory (~/.config/sdkt/identities/).

If the SDKT_IDENTITY_DIR environment variable is set, its value is used instead of the OS-default config directory. This provides a cross-platform override (works on macOS and Windows, where XDG_CONFIG_HOME is ignored by directories::ProjectDirs), and is the canonical way for tests and CI to isolate the identity store.

Source

pub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self, StorageError>

Initialize the keystore in a custom directory.

Source

pub fn generate(&self, name: &str) -> Result<Identity, StorageError>

Generate a new random ED25519 identity.

Source

pub fn import( &self, name: &str, secret_key: &str, ) -> Result<Identity, StorageError>

Import an identity from a secret key (S…) string.

Source

pub fn get(&self, name: &str) -> Result<Identity, StorageError>

Load an identity by name.

Source

pub fn resolve_signing_identity( &self, name: &str, ) -> Result<Identity, StorageError>

Resolve the signing identity named by a CLI --identity value.

The signing commands default --identity to the reserved literal DEFAULT_IDENTITY_NAME ("default"), which can never be a real key. When name is that sentinel this returns the identity selected by IdentityStore::set_default; for any other name it is exactly IdentityStore::get, so an explicit --identity <name> is unchanged.

§Errors

Returns StorageError::NoDefaultIdentity when the sentinel is used and no default has been configured, and the IdentityStore::get error for any other unresolvable name.

Source

pub fn remove(&self, name: &str) -> Result<(), StorageError>

Delete an identity.

Returns StorageError::NotFound when no identity with that name exists, matching NetworkStore::remove, so a mistyped name is reported rather than treated as a successful removal.

Source

pub fn list(&self) -> Result<Vec<Identity>, StorageError>

List all stored identities.

Source

pub fn set_default(&self, name: &str) -> Result<(), StorageError>

Set an identity as the default.

Source

pub fn get_default(&self) -> Result<Identity, StorageError>

Load the default identity.

Source

pub fn load_signing_key(&self, name: &str) -> Result<SigningKey, StorageError>

Load the signing key (ed25519_dalek::SigningKey) for a named identity.

This is the keystore integration point used by transaction signing: the caller extracts the 32-byte seed via signing_key.to_bytes() and passes it to sdkt_xdr::Ed25519Signer::from_seed. The secret material is never exposed as a string; only the in-memory SigningKey is returned, and only for the duration the caller holds it.

§Errors

Returns StorageError if the identity does not exist or its secret cannot be loaded.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more