pub struct ConfigurableClientHost<S: ClientStorage> { /* private fields */ }Expand description
A configurable client host that holds raw secret keys and uses pluggable storage.
This provides a batteries-included implementation of SpilmanClientHost for
applications that want to manage keys directly. For hardware wallet integration
or external signers, implement SpilmanClientHost directly instead.
§Key Management
Keys are stored in a HashMap indexed by their public key (hex-encoded). When signing operations are requested, the host looks up the corresponding secret key by the provided public key.
§Storage
Channel data is stored via a ClientStorage implementation. The default
MemoryClientStorage keeps everything in memory. For persistence, implement
ClientStorage for your preferred backend.
§Thread Safety
The storage is wrapped in RefCell for interior mutability, allowing
the trait methods (which take &self) to modify storage. This means
ConfigurableClientHost is not Sync and cannot be shared across threads.
For multi-threaded use, wrap in Mutex or use a thread-safe storage backend.
Implementations§
Source§impl<S: ClientStorage> ConfigurableClientHost<S>
impl<S: ClientStorage> ConfigurableClientHost<S>
Sourcepub fn add_key(&mut self, secret: SecretKey)
pub fn add_key(&mut self, secret: SecretKey)
Add a keypair to the host.
The key is indexed by its public key (hex-encoded). If a key with the same public key already exists, it is replaced.
Sourcepub fn add_key_from_hex(&mut self, secret_hex: &str) -> Result<String, String>
pub fn add_key_from_hex(&mut self, secret_hex: &str) -> Result<String, String>
Add a keypair from hex-encoded secret key.
Returns an error if the hex string is invalid.
Sourcepub fn get_pubkeys(&self) -> Vec<String>
pub fn get_pubkeys(&self) -> Vec<String>
Get the public keys of all stored keys.
Sourcepub fn has_key(&self, pubkey_hex: &str) -> bool
pub fn has_key(&self, pubkey_hex: &str) -> bool
Check if a key exists for the given public key.
Sourcepub fn remove_key(&mut self, pubkey_hex: &str) -> bool
pub fn remove_key(&mut self, pubkey_hex: &str) -> bool
Remove a key by public key.
Returns true if a key was removed, false if no key existed.
Sourcepub fn storage_mut(&mut self) -> &mut S
pub fn storage_mut(&mut self) -> &mut S
Get mutable access to the underlying storage.
Use with caution - this bypasses the normal host interface.
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Get the number of stored channels.
Source§impl ConfigurableClientHost<MemoryClientStorage>
impl ConfigurableClientHost<MemoryClientStorage>
Sourcepub fn new_in_memory() -> Self
pub fn new_in_memory() -> Self
Create a new configurable client host with in-memory storage.
This is a convenience constructor for the common case of using
MemoryClientStorage.