pub trait DiscoverableKeyProvider: KeyProvider {
// Required methods
fn get_derivation_index_for_pk(&self, pk: &XOnlyPublicKey) -> Option<u32>;
fn derive_at_discovery_index(
&self,
index: u32,
) -> Result<Option<Keypair>, Error>;
fn cache_discovered_keypair(
&self,
index: u32,
kp: Keypair,
) -> Result<(), Error>;
fn cache_keypair_at_index(&self, index: u32) -> Result<(), Error>;
fn mark_as_used(&self, pk: &XOnlyPublicKey) -> Result<(), Error>;
}Expand description
Key provider extension for index-based discovery and restore.
Required Methods§
Sourcefn get_derivation_index_for_pk(&self, pk: &XOnlyPublicKey) -> Option<u32>
fn get_derivation_index_for_pk(&self, pk: &XOnlyPublicKey) -> Option<u32>
Get the derivation index for a cached public key.
Sourcefn derive_at_discovery_index(
&self,
index: u32,
) -> Result<Option<Keypair>, Error>
fn derive_at_discovery_index( &self, index: u32, ) -> Result<Option<Keypair>, Error>
Derive a keypair at a specific index without caching.
Sourcefn cache_discovered_keypair(&self, index: u32, kp: Keypair) -> Result<(), Error>
fn cache_discovered_keypair(&self, index: u32, kp: Keypair) -> Result<(), Error>
Cache a discovered keypair at the given index.
This is called after discovery determines a key is “used” (has VTXOs). Implementations should also advance receive-key state to avoid reuse.
Sourcefn cache_keypair_at_index(&self, index: u32) -> Result<(), Error>
fn cache_keypair_at_index(&self, index: u32) -> Result<(), Error>
Derive and cache the keypair at a persisted derivation index.
This is used after loading persisted contracts so HD wallets can sign for stored contracts immediately after restart, without running a full restore scan. Implementations must not advance receive-key discovery state here.
fn mark_as_used(&self, pk: &XOnlyPublicKey) -> Result<(), Error>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".