Skip to content

Make BDK_CLIENT_STOP_GAP and BDK_WALLET_SYNC_TIMEOUT_SECS configurable #843

@Copexit

Description

@Copexit

Problem

BDK_CLIENT_STOP_GAP (20) and BDK_WALLET_SYNC_TIMEOUT_SECS (20s) are hardcoded constants in config.rs:

pub(crate) const BDK_CLIENT_STOP_GAP: usize = 20;

const DEFAULT_LDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 30;

When a wallet has generated more than 20 consecutive unused addresses and needs to recover from keys_seed with a fresh database, BDK's full scan stops at the gap limit and fails to discover UTXOs at higher derivation indices. The funds appear lost even though they're on-chain and spendable.

What happened

Learned this once I already "lost funds". Could happen to anyone who simply spams the "generate address" button 20 times on a fully working wallet. Once he needs to recover from seed, funds won't show.

Proposal

Expose both values as configurable fields on the Config struct (or as Builder methods), with the current values as defaults.

This would allow wallet recovery without forking or patching the crate. The defaults remain conservative (20 / 30s) for normal operation, but operators/integrationrs can increase them or allow configuration for recovery scenarios.

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