Skip to content

Unintuitive and undocumented full_scan behavior #2057

Closed
bitcoindevkit/bdk-ffi
#1142

Description

@andreasgriffin

Book of BDK has a overview of the expected sync behavior

Image

However full_scan seems to completely ignore the revealed addresses and goes by the gap only. This means that if there is a large gap it will not discover any transactions even though the addresses are already revealed. A sync will discover those transactions, such that for a "full scan" one has to do full_scan and sync .

Thanks to @design-rrr for finding this behavior.

  • Reproducible in bdkpython 2.0.0

Why not do sync most of the time?

  • onchain wallets can have multiple instances running, that reveal and use scripts. That means that the wallet always has to sync at least the gap limit ahead to discover txs that other instances used.

What to do about it?

  • Was this behavior intended?
    • But then to do a full scan, one has to hit the server twice... --> inefficient

@thunderbiscuit @ValuedMammal

Activity

  1. changed the title [-]Unintuitive and undocumented `sync` and `full_scan` behavior[/-] [+]Unintuitive and undocumented `full_scan` behavior[/+] on Oct 5, 2025
  2. ValuedMammal commented on Oct 6, 2025

    @ValuedMammal
    Contributor

    To avoid further confusion I want to propose that we eliminate full-scan and consolidate the sync and full-scan logic into a single sync workflow that keeps the existing sync behavior while making use of the stop-gap functionality.

  3. oleonardolima commented on Oct 8, 2025

    @oleonardolima
    Contributor

    I've moved this issue to bitcoindevkit/bdk, as it applies to bdk_electrum/esplora and not the rust-electrum-client.

  4. moved this to Discussion in BDK Chainon Oct 8, 2025
  5. added
    documentation
    discussion
    on Oct 8, 2025
  6. evanlinjin commented on Apr 17, 2026

    @evanlinjin
    Contributor

    I think the current behavior is working as intended — full_scan does keychain discovery using the stop gap, and sync checks known scripts. These are separate operations with different purposes.

    That said, the issue is valid: callers shouldn't need to call both full_scan and sync to ensure all revealed scripts are checked during discovery. The fix is straightforward — give full_scan awareness of the last revealed index so the stop gap only applies beyond that point. This way full_scan always covers 0..=last_revealed and then continues discovery until the stop gap is hit.

    I don't think we should unify full_scan and sync into a single API. They have fundamentally different inputs and use cases:

    • full_scan takes keychains and a stop gap — it's for discovery
    • sync takes explicit lists of scripts/txids/outpoints — it's for checking known items

    Merging them adds API complexity without adding capability. Callers that only need one (e.g. sync for routine polling, full_scan for wallet restoration) would be forced to interact with a larger API surface.

    The targeted fix is to add a last_revealed_by_keychain parameter (or derive it from the indexer) so full_scan knows the minimum range to cover before applying the stop gap.

  7. andreasgriffin commented on Apr 17, 2026

    @andreasgriffin
    Author

    give full_scan awareness of the last revealed index

    would work for me :-)

  8. moved this from Discussion to Done in BDK Chainon Apr 24, 2026
  9. added a commit that references this issue on Apr 25, 2026
    7ea8b63
  10. added a commit that references this issue on Jun 9, 2026
  11. moved this from Done to In Progress in BDK Chainon Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussiondocumentation

    Type

    No type

    Projects

    • Status
      In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions