Skip to content

Explicitly fail build when we cannot decode persisted AddressPool. - #1238

Open
randomlogin wants to merge 1 commit into
lightningdevkit:mainfrom
randomlogin:nov-26-fail-on-undecodable-address-pool
Open

randomlogin wants to merge 1 commit into
lightningdevkit:mainfrom
randomlogin:nov-26-fail-on-undecodable-address-pool

Conversation

@randomlogin

@randomlogin randomlogin commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1212.

As with other storage readings, we fail the build if we cannot read it (despite the fact that failing to read AddressPool is less severe than other failed readings).

NotFound stays a fresh pool: every node upgrading from v0.7.x has no record yet, and revealing fresh indices is correct for them.

@ldk-reviews-bot

ldk-reviews-bot commented Nov 16, 2026 •

Copy link
Copy Markdown

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@Camillarhi Camillarhi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I left a few comments

Nit: the commit message says "losing handed addresses", but the addresses lost are pooled ones that were never handed out. Something like "skipping pooled derivation indices" would be more accurate. Also a double space in "decode persisted".

Comment thread src/wallet/persist.rs
Comment on lines +253 to +256
///
/// Fails if the record exists but cannot be decoded: an established wallet would otherwise
/// start with an empty pool and reveal fresh indices past the old pooled ones, leaving them
/// revealed but never handed out, which widens the gap a restore from seed must scan across.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now contradicts the doc on AddressPoolRecord, which still describes the record as "advisory and reconstructible". Could we update that doc too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

Comment thread src/wallet/mod.rs

#[tokio::test]
async fn loading_survives_an_undecodable_pool_record() {
async fn loading_fails_on_an_undecodable_pool_record() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1212 asks for a test of both a corrupt record and a deleted record against a wallet that already has persisted reveals. This covers the corrupt case. Could we add one for the deleted case too, asserting the current NotFound behaviour?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Previously we continued the build after failing to decode the persisted
`AddressPool`, which skipped the pooled derivation indices: they stayed
revealed but were never handed out. Now we explicitly fail the build in
that case. A missing record still starts a fresh pool, as for wallets
that predate the pool.
@randomlogin
randomlogin force-pushed the nov-26-fail-on-undecodable-address-pool branch from ea4b91e to 0f9a345 Compare November 17, 2026 22:19
@randomlogin

Copy link
Copy Markdown
Contributor Author

Amended the commit.

@Camillarhi Camillarhi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM!

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.

Established wallets silently lose pooled addresses when the pool record is missing or undecodable

3 participants