Skip to main content

DiscoverableKeyProvider

Trait DiscoverableKeyProvider 

Source
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§

Source

fn get_derivation_index_for_pk(&self, pk: &XOnlyPublicKey) -> Option<u32>

Get the derivation index for a cached public key.

Source

fn derive_at_discovery_index( &self, index: u32, ) -> Result<Option<Keypair>, Error>

Derive a keypair at a specific index without caching.

Source

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.

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl<T: DiscoverableKeyProvider + ?Sized> DiscoverableKeyProvider for Arc<T>

Implementors§