Skip to content

feat: add wallet recovery flows to bdk_demo#65

Merged
reez merged 6 commits intobitcoindevkit:mainfrom
Johnosezele:feat(bdk-demo)/wallet-recovery
Apr 30, 2026
Merged

feat: add wallet recovery flows to bdk_demo#65
reez merged 6 commits intobitcoindevkit:mainfrom
Johnosezele:feat(bdk-demo)/wallet-recovery

Conversation

@Johnosezele
Copy link
Copy Markdown
Contributor

@Johnosezele Johnosezele commented Apr 20, 2026

This PR addresses issue #5

Notes to reviewers

  • validateRecoveryPhrase() does local word-count and word-membership checks, then delegates checksum validation to BDK via Mnemonic.fromString(). This keeps validation fast and user-friendly without duplicating checksum logic outside the library that already owns it.
  • _buildAndPersistWallet(...) is an internal refactor seam introduced to keep createWallet() and the new recovery flows aligned on name validation, persistence, and disposal-on-failure behavior. That refactor is intentionally isolated so reviewers can verify the no-behavior-change step separately from the feature additions.
  • Descriptor recovery intentionally stores recovered wallets as ScriptType.unknown. A raw descriptor string may be watch-only or secret bearing, and this PR does not claim the app can reliably infer spend capability from descriptor shape alone. The safer contract here is local reconstruction and persistence only, with explicit spend capability, surfacing is deferred to later work once the app is able to demonstrate this model across service and UI layers.
  • This PR supports both 12-word and 24-word English BIP-39 phrases.
  • RecoverWalletPage mirrors CreateWalletPage patterns for snackbar feedback, mounted guards, and provider ownership.
  • Follow-up work: BIP-39 passphrase support is intentionally out of scope for this PR and is tracked as a future roadmap item.

New features

  • Add English BIP-39 word list support and validateRecoveryPhrase() with user-friendly recovery validation errors.
  • Add _buildAndPersistWallet(...) as a shared, so create and recover flows use the same persistence and cleanup rules.
  • Add WalletService.recoverFromPhrase(name, network, scriptType, phrase) and WalletService.recoverFromDescriptors(name, network, descriptor, changeDescriptor).
  • Add RecoverWalletPage and route /recover-wallet to the recovery flow.
  • Add feature-scoped recovery tests under test/features/wallet_setup/.

@Johnosezele Johnosezele marked this pull request as ready for review April 27, 2026 10:14
@Johnosezele
Copy link
Copy Markdown
Contributor Author

Johnosezele commented Apr 27, 2026

@reez @j-kon
this pr is ready for review,
a tACK will be helpful.

Copy link
Copy Markdown
Contributor

@j-kon j-kon left a comment

Choose a reason for hiding this comment

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

Nice work on wiring recovery through the service, UI, route, and tests. I left a few small comments around keeping BIP-39 validation aligned with BDK as the source of truth, plus one sensitive-input hardening suggestion. The flow is understandable and well-covered overall.

Comment thread bdk_demo/lib/services/wallet_service.dart
Comment thread bdk_demo/lib/services/wallet_service.dart
Comment thread bdk_demo/lib/features/wallet_setup/recover_wallet_page.dart
@reez
Copy link
Copy Markdown
Collaborator

reez commented Apr 30, 2026

just needs a rebase and then I will merge

Copy link
Copy Markdown
Collaborator

@reez reez left a comment

Choose a reason for hiding this comment

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

ACK 45206f7

Copy link
Copy Markdown
Contributor

@j-kon j-kon left a comment

Choose a reason for hiding this comment

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

ACK

@Johnosezele Johnosezele force-pushed the feat(bdk-demo)/wallet-recovery branch from 45206f7 to f2e50a5 Compare April 30, 2026 17:21
@Johnosezele Johnosezele force-pushed the feat(bdk-demo)/wallet-recovery branch from f2e50a5 to 3bc67dd Compare April 30, 2026 17:32
Copy link
Copy Markdown
Collaborator

@reez reez left a comment

Choose a reason for hiding this comment

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

ACK 3bc67dd

@reez reez merged commit 6bdf9a8 into bitcoindevkit:main Apr 30, 2026
5 checks passed
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.

3 participants