Skip to content

Add receive address generation for bdk_demo#79

Merged
reez merged 5 commits into
bitcoindevkit:mainfrom
Johnosezele:feat/receive-address-gen
Jun 15, 2026
Merged

Add receive address generation for bdk_demo#79
reez merged 5 commits into
bitcoindevkit:mainfrom
Johnosezele:feat/receive-address-gen

Conversation

@Johnosezele

Copy link
Copy Markdown
Contributor

Adds a persisted walletService generation path plus Riverpod state for the current generated receive address. This PR does not replace the /receive placeholder UI yet; it prepares the service/provider layer for that follow-up.

Notes to Reviewers:

  • Receive generation uses revealNextAddress, not nextUnusedAddress, so revealed script pubkeys can be tracked by later sync work.

  • WalletService.generateAddress(record) loads by wallet record before revealing, then returns the updated wallet so provider wiring can replace the active wallet instance.

Resolves #78

@Johnosezele

Copy link
Copy Markdown
Contributor Author

I cut #80 into this PR

record,
);

if (!_stillActive(walletId)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This stale branch runs after generateAddress() has already revealed and persisted the address for the old wallet. Could we either avoid committing when _stillActive(walletId) is false, or cache the generated address by wallet id so it is shown when that wallet becomes active again? Otherwise switching wallets during generation advances the old wallet’s receive index without ever surfacing the address.

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.

I agree, what I want to do here is keep the generated receive address keyed by walletId instead of dropping it when the user switches wallets mid-generation... that way we still avoid showing stale state on the newly active wallet, but when the original wallet becomes active again we can show the address that was already revealed and persisted. I’ll also add a test for that path so the behavior is locked in.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yep, that behavior makes sense to me. Since the address has already been revealed and persisted by the time the stale completion returns, we shouldn’t drop it. Caching the result by walletId seems right. One thing to tighten before resolving: the cached wallet ownership path looks fragile, and CI is currently panicking in the reactivation test, so I’d either cache just the receive-address state and reload the wallet from SQLite, or make the cached-wallet handoff explicit and covered by the test.

@Johnosezele Johnosezele Jun 12, 2026

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.

Yep, agreed. I’m going to cache only the receive address state by walletId, and dispose the stale returned wallet.

Comment thread bdk_demo/lib/providers/address_providers.dart Outdated
@Johnosezele Johnosezele requested a review from reez June 12, 2026 04:10

@reez reez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK 960989e

@reez reez merged commit 558a8da into bitcoindevkit:main Jun 15, 2026
5 checks passed
@reez

reez commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

great job!

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.

bdk_demo: Add persisted receive address generation to the demo wallet

2 participants