Add receive address generation for bdk_demo#79
Conversation
|
I cut #80 into this PR |
| record, | ||
| ); | ||
|
|
||
| if (!_stillActive(walletId)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yep, agreed. I’m going to cache only the receive address state by walletId, and dispose the stale returned wallet.
|
great job! |
Adds a persisted walletService generation path plus Riverpod state for the current generated receive address. This PR does not replace the
/receiveplaceholder UI yet; it prepares the service/provider layer for that follow-up.Notes to Reviewers:
Receive generation uses
revealNextAddress, notnextUnusedAddress, 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