Skip to content

Add --rescan-from-height CLI argument#196

Draft
tnull wants to merge 1 commit intolightningdevkit:mainfrom
tnull:2026-04-rescan-from-height-arg
Draft

Add --rescan-from-height CLI argument#196
tnull wants to merge 1 commit intolightningdevkit:mainfrom
tnull:2026-04-rescan-from-height-arg

Conversation

@tnull
Copy link
Copy Markdown
Collaborator

@tnull tnull commented Apr 21, 2026

Based on lightningdevkit/ldk-node#884
Draft for now.

Expose the ldk-node wallet-recovery API through a new top-level CLI flag (also overridable via the LDK_SERVER_RESCAN_FROM_HEIGHT environment variable). When set on a fresh node's first startup, the value is passed through to
Builder::set_wallet_recovery_mode(Some(RecoveryMode { rescan_from_height: Some(h) })) so the wallet picks up funds sent before the current chain tip.

Bitcoin Core RPC/REST chain sources honor the height precisely by resolving the block hash at h and using it as the wallet birthday. Esplora/Electrum backends cannot resolve a block hash from a height via the BDK client APIs, so they ignore the value but still escalate the next sync to a one-shot full_scan to re-discover funds on previously-unknown addresses.

The ldk-node dependency is temporarily pointed at the local 2026-04-abort-on-first-startup-tip-fetch-failure worktree since the RecoveryMode API is not yet on ldk-node's upstream main; the Cargo.toml entry should be restored to a pinned upstream git rev once that branch merges.

Co-Authored-By: HAL 9000

Expose the ldk-node wallet-recovery API through a new top-level CLI
flag (also overridable via the `LDK_SERVER_RESCAN_FROM_HEIGHT`
environment variable). When set on a fresh node's first startup, the
value is passed through to
`Builder::set_wallet_recovery_mode(Some(RecoveryMode { rescan_from_height: Some(h) }))`
so the wallet picks up funds sent before the current chain tip.

Bitcoin Core RPC/REST chain sources honor the height precisely by
resolving the block hash at `h` and using it as the wallet birthday.
Esplora/Electrum backends cannot resolve a block hash from a height
via the BDK client APIs, so they ignore the value but still escalate
the next sync to a one-shot `full_scan` to re-discover funds on
previously-unknown addresses.

The `ldk-node` dependency is temporarily pointed at the local
`2026-04-abort-on-first-startup-tip-fetch-failure` worktree since the
`RecoveryMode` API is not yet on ldk-node's upstream main; the
Cargo.toml entry should be restored to a pinned upstream git rev once
that branch merges.

Co-Authored-By: HAL 9000
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 21, 2026

👋 Hi! This PR is now in draft status.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@tnull tnull marked this pull request as draft April 21, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants