Skip to content

Consider adding visibility into the SyncRequest type #2220

@thunderbiscuit

Description

@thunderbiscuit

Once created, a SyncRequest cannott be inspected to know which spks will be synced. The inspect callback provides that information but only once the sync is already in motion and there is no way to query the request at rest.

Note that for Wallet users there is a workaround: wallet.spk_index().revealed_spks(..) gives the full list of spks, but this requires going back to the wallet rather than reading the already-constructed request, and is not available to callers working directly with bdk_core.

Proposed draft addition to SyncRequest:

pub fn iter_spks(&self) -> impl Iterator<Item = &(I, ScriptBuf)> {
    self.spks.iter()
}

For symmetry, non-consuming iterators for txids and outpoints could be added at the same time, potentially with:

pub fn iter_txids(&self) -> impl Iterator<Item = &Txid> {
    self.txids.iter()
}

pub fn iter_outpoints(&self) -> impl Iterator<Item = &OutPoint> {
    self.outpoints.iter()
}

Note that counts for all three are already available via progress(). This issue proposes only to add access to the actual contents without consuming the request.

Impact

  • Blocking production usage
  • Nice-to-have / UX improvement
  • Developer experience / maintainability

Are you using BDK in a production project?

  • Yes
  • No
  • Not yet, but planning to

Which backend(s) are relevant (if any)?

  • Electrum
  • Esplora
  • Bitcoin Core RPC
  • None / not backend-related (e.g. bdk_chain, bdk_core)
  • Other (please specify): ____

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions