Skip to content

Electrum chain source omits the regtest fast-sync override applied to Esplora #54

@hash-money

Description

@hash-money

Summary

When ChainSource::Electrum is selected on Network::Regtest, the chain
source is configured with set_chain_source_electrum(url, None). This causes
ldk-node to fall back to its default BackgroundSyncConfig (80s on-chain,
30s lightning). The same configuration with ChainSource::Esplora on
Network::Regtest instead applies a 2s/2s/30s BackgroundSyncConfig.

Where

orange-sdk/src/lightning_wallet.rs:

match config.chain_source {
    ChainSource::Esplora { url, username, password } => {
        let sync_config = if config.network == Network::Regtest {
            ldk_node::config::EsploraSyncConfig {
                background_sync_config: Some(BackgroundSyncConfig {
                    onchain_wallet_sync_interval_secs: 2,
                    lightning_wallet_sync_interval_secs: 2,
                    fee_rate_cache_update_interval_secs: 30,
                }),
            }
        } else {
            ldk_node::config::EsploraSyncConfig::default()
        };
        // ... sync_config is passed into set_chain_source_esplora
    },
    ChainSource::Electrum(url) => builder.set_chain_source_electrum(url, None),
    // ^ no regtest-aware sync_config; passes None
    ChainSource::BitcoindRPC { .. } => { ... },
};

Effect

Regtest workflows using the Electrum chain source observe ~80s feedback
cycles for incoming on-chain detection, vs. the ~2s the Esplora regtest path
provides. ldk_node::Builder::set_chain_source_electrum accepts an
Option<ElectrumSyncConfig> with the same shape as EsploraSyncConfig, so
the override pattern already used a few lines above is directly portable.

Suggested fix

Mirror the Esplora regtest override on the Electrum arm:

ChainSource::Electrum(url) => {
    let sync_config = if config.network == Network::Regtest {
        Some(ldk_node::config::ElectrumSyncConfig {
            background_sync_config: Some(BackgroundSyncConfig {
                onchain_wallet_sync_interval_secs: 2,
                lightning_wallet_sync_interval_secs: 2,
                fee_rate_cache_update_interval_secs: 30,
            }),
        })
    } else {
        None
    };
    builder.set_chain_source_electrum(url, sync_config)
},

Mainnet behavior is unchanged — the else None branch preserves ldk-node
defaults. Happy to open a PR if useful.

Environment

  • orange-sdk rev 2762df2
  • ldk-node 0.7.0

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