Skip to content

feat(dash-spv-ffi): expose MasternodeListEngine accessor on FFIDashSpvClient #607

@QuantumExplorer

Description

@QuantumExplorer

Summary

FFIDashSpvClient.inner is currently pub(crate), which prevents external crates (like rs-sdk-ffi in the platform repo) from accessing the MasternodeListEngine directly. This forces a round-trip through C-style FFI functions (ffi_dash_spv_get_quorum_public_key) even when calling from Rust code in the same binary.

What's needed

Add a public accessor on FFIDashSpvClient that returns the masternode list engine:

impl FFIDashSpvClient {
    /// Returns the shared masternode list engine, if initialized.
    pub fn masternode_list_engine(&self) -> Option<Arc<RwLock<MasternodeListEngine>>> {
        self.inner.masternode_list_engine().ok()
    }

    /// Returns the network this client is configured for.
    pub fn network(&self) -> Network {
        self.runtime.block_on(async { self.inner.network().await })
    }
}

Why

Platform repo has a pure-Rust SpvContextProvider in platform-wallet (PR #3417) that implements the ContextProvider trait by reading quorum data directly from Arc<RwLock<MasternodeListEngine>> — zero FFI. But currently the FFI bridge in rs-sdk-ffi can't use it because it can't extract the engine from FFIDashSpvClient.

Once this accessor exists, rs-sdk-ffi can replace its FFI bridge with:

let engine = ffi_client.masternode_list_engine().expect("not initialized");
let network = ffi_client.network();
let provider = platform_wallet::SpvContextProvider::new(engine, network);
sdk_builder.with_context_provider(provider);

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions