bitcoindevkit / bitcoindevkit/bdk

Consider adding visibility into the `SyncRequest` type

Open
#2,220 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
1.1k
Forks
483
Avg merge
20d 3h
Merged PRs (30d)
3

Description

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`:

```rust
pub fn iter_spks(&self) -> impl Iterator {
self.spks.iter()
}
```

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

```rust
pub fn iter_txids(&self) -> impl Iterator {
self.txids.iter()
}

pub fn iter_outpoints(&self) -> impl Iterator {
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
- [x] Nice-to-have / UX improvement
- [ ] Developer experience / maintainability

**Are you using BDK in a production project?**
- [x] 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): `____`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.